Generic or specific?
Making sensible software design decisions
Generic or Specific? Making Sensible Software Design Decisions
bertjan@openvalue.eu
Making sensible software design decisions
Bert Jan Schrijver
@bjschrijver
Generic or specific?
Bert Jan Schrijver
L e t ’ s m e e t
@bjschrijver
Levels of
generic vs specific
Tools to help decide
Flexibility in software
Definitions
When & why to go
generic
Sharing code in
an organization
Conclusion
Outline
W h a t ‘ s n e x t ?
The cost of generic
@bjschrijver
What is software design?
Design vs architecture
• Tailor made for use in a single place
• Tailored to a specific problem or scenario
• May not be easily adaptable to other
situations
Specific solution (or design)
• More flexible and reusable solution
• Solution can be applied to a wide range of
problems or scenarios
• Generified solution that can be used in
more than 1 place
Generic solution (or design)
Background source: https://filmquarterly.org/2012/07/02/i-robot-what-do-robots-dream-of/
• Breaking a system or problem into
smaller parts that are easier to
understand
• Example: Google search
Hierarchical decomposition
Background source: DALL·E
Hierarchical decomposition
Source: https://c4model.com
• Kind and degree of interdependence
between building blocks of software
• Measure of how closely connected two
components are
• Usually contrasted with cohesion
(low coupling -> high cohesion)
Coupling
Background source: DALL·E
• Inheritance
• Messages or events
• Temporal
• Data types
• Data
• Code / API (binary or source)
Types of coupling
Background source: DALL·E
Be careful with coupling!
Generic solution = coupling!
The risk of DRY
Duplicated code doesn’t hurt
until you need to change it.
• Should we be prepared for future
changes?
• Design should be structured to
accommodate change
• Risk management: risk of wrong decision
“Future proof” design
Background source: DALL·E
About flexibility in software…
“Highly specific code is often preferable
to sophisticated configuration”
- Stefan Tilkov
When are we going to talk
about generic vs specific?
Background source: https://7216-presscdn-0-76-pagely.netdna-ssl.com/wp-content/uploads/2011/12/confused-man-single-good-men.jpg
• Code / class level
• Manually written vs generated code
• Library level
• Data level
• (Micro)service level
• Organisation level
Generic vs specific: levels
Background source: DALL·E
Generic or specific?
• Do we really need this now? (YAGNI)
• The 5 W’s
• Time/effort for generic vs specific
• Myth of “first time right”
• Complexity and scope
• The rule of three
• Future needs and evolution
Tools to help decide
• When reusing code, copy it once, and only
abstract the third time
• Avoid writing the wrong abstraction
• It’s easier to make a good abstraction from
duplicated code than to refactor the wrong
abstraction
• "Three strikes and you refactor"
The rule of three
Background source: https://learntalk.org/en/blog/where-did-the-saying-third-times-the-charm-come-from
• First case: Just build it, don’t genericise at all.
Solve the problem in front of you (YAGNI)
• Second case: Duplicate the original, redesign and
extract common behaviour while you change
• Third case: examine lessons from first two
passes, design a generic solution that will make it
easy to add your third case
The rule of three
Background source: https://learntalk.org/en/blog/where-did-the-saying-third-times-the-charm-come-from
• Pass 1: YAGNI / rule of three: as simple and specific as
possible
• Pass 2: based on solution domain knowledge:
is a generic solution less work?
• Pass 3: based on problem domain knowledge:
is the easiest solution actually correct?
• Pass 4: looking at customer behaviour or other non
technical considerations, does this change your decision?
Design heuristics
Background source: DALL·E
• Concept from Domain Driven Design
• Tool to help decide for generic vs specific
• But more about building yourself or not
• Subdomains:
• Core domain
• Supporting subdomain
• Generic subdomain
Strategic design
Background source: GR Stocks on Unsplash
• Organizations design systems that mirror
their own communication structure
• Don’t force a solution that goes against
the organisation structure
• Be careful to go generic when teams don’t
want to work together
Conway’s law
Background source: DALL·E
Conway’s law in action
Background source: DALL·E
• Another rule of three: building reusable
components is 3x as difficult as single use
• The price you pay is coupling
• Both on code level and people/team level
(communication overhead)
The cost of a generic solution
Background source: DALL·E
What if you get it wrong?
Photo: Dave Lehl
• Efficiency gains of a generic solution are
typically clear, but how about:
• Onboarding new people
• Readability
• Coupling
The cost of abstractions
Background source: Héctor J. Rivas on Unsplash
• Writing bad abstractions
• Writing unnecessary reusable code
• Introducing unnecessary coupling
• Maintaining bad abstractions
• Hard to see
• Hard to understand
• Hard to extend
The cost of abstractions
Background source: Héctor J. Rivas on Unsplash
When / why to go generic
• ”We’ve always done it like this”
• “We don’t want to depend on libraries”
• “We need to be future proof”
• Because the product owner wants it
• Because the architect wants it
Bad reasons to go generic
• Rule of three checks out
• You’re pretty sure you’re going to need it
almost everywhere
• A library that lots of teams will use
• Complex logic or skills that only a couple of
people have
• Gains are bigger than cost
Valid reasons to go generic
• Think back about the layers in hierarchical
decomposition of a system
• Code vs component vs service
• Are the considerations for generic vs specific the
same on every level?
• Risk when getting it wrong is higher when the level
is higher
• Don’t confuse generification with standardization!
Generic vs specific in different scopes
Background source: Fernando Gomez on Unsplash
Why specific is often faster
Code golf
Advent of code
Generic or Specific? Making Sensible Software Design Decisions
Generic or Specific? Making Sensible Software Design Decisions
Generic or Specific? Making Sensible Software Design Decisions
Generic or Specific? Making Sensible Software Design Decisions
Exception handling
Generic or Specific? Making Sensible Software Design Decisions
Website code re-use
49
Generic solutions on organization level
• Sharing code efficiently at scale is hard
• Sharing code at scale means:
• Multiple modules that share code
• Multiple team members
• High rate of change
• Little to no loss of individual productivity
Sharing code within an organization
Source: https://medium.com/@jeffwhelpley/the-problem-with-shared-code-124a20fc3d3b
• Challenges:
• Refactoring
• Versioning
• Reviewing
• Builds and codebase size - monorepo?
Sharing code within an organization
Source: https://medium.com/@jeffwhelpley/the-problem-with-shared-code-124a20fc3d3b
• Monorepo: 1 large repository for a group of
projects (possible all projects)
• Good: easy to make changes across projects
• Bad: dependencies & build times
Monorepositories
Background source: DALL·E
• Discovery: what code / libraries exist?
• Distribution: binary or source dependency?
• Import: well defined API’s or chaos?
• Versioning, upgrades and lifecycle
management
• Who maintains it?
• Possible approach: inner source culture
Considerations on sharing code in an org
Source: https://medium.com/@jeffwhelpley/the-problem-with-shared-code-124a20fc3d3b, background source: Klara Kulikova on Unsplash
Summary
• Consider:
• YAGNI / Rule of three / 5 W’s
• Cost of generic
• Scope / level
• Conway’s law
• Organization
Generic or specific?
Generic or specific?
It depends.
A program that works perfectly but is
impossible to change will become
useless.
A program that does not work but is easy
to change will become and remain useful
continuously.
Source: Clean Architecture, Robert C. Martin
Generic or Specific? Making Sensible Software Design Decisions
NOW GO KICK SOME ASS!
Questions?
@bjschrijver
Thanks for your time.
Got feedback? Tweet it!
All pictures belong
to their respective
authors
@bjschrijver
Generic or Specific? Making Sensible Software Design Decisions

More Related Content

PPTX
E.b.d adultos 1ºtrimestre 2017 lição 01
PPT
Hitler, o quase anticristo
PPTX
Lição 05 (1° 16) o arrebatamento da igreja
PPTX
Halloween.simceros
PDF
Paul washer o_unico_deus_verdadeiro
PDF
Disciplemaking introduction
PPTX
Vencendo as Aflições da Vida
PDF
E.b.d adultos 1ºtrimestre 2017 lição 01
Hitler, o quase anticristo
Lição 05 (1° 16) o arrebatamento da igreja
Halloween.simceros
Paul washer o_unico_deus_verdadeiro
Disciplemaking introduction
Vencendo as Aflições da Vida

What's hot (18)

PPT
Lição 06 - Tiatira, a igreja tolerante
PPTX
2025 - PPT_Sermão 07 - Quartas de Poder - PT.pptx
PPTX
07 tipos de pecado
PDF
Considerações sobre o Apocalipse Esquematizado
PPTX
O arrebatamento da igreja
PPS
A Morte De Jesus
PPTX
Good Friday
PPSX
O Reino das Trevas
DOC
Bruce wilkinson além de jabez
PPT
2 mistério
PDF
Mensagens reveladas na palavra de deus 2
PPTX
Dios y su caracter
PDF
Salmo 124 estudo
PPTX
Como vai sua família? Vai tudo bem?
PPT
Deus é o Oleiro Nós o Barro
DOCX
Estudos sobre os nomes de alguns demonios e suas atuações
PPSX
No tempo de deus.pubpptx
PPTX
CARTA DE PAULO AOS FILIPENSES, CAPÍTULO 2
Lição 06 - Tiatira, a igreja tolerante
2025 - PPT_Sermão 07 - Quartas de Poder - PT.pptx
07 tipos de pecado
Considerações sobre o Apocalipse Esquematizado
O arrebatamento da igreja
A Morte De Jesus
Good Friday
O Reino das Trevas
Bruce wilkinson além de jabez
2 mistério
Mensagens reveladas na palavra de deus 2
Dios y su caracter
Salmo 124 estudo
Como vai sua família? Vai tudo bem?
Deus é o Oleiro Nós o Barro
Estudos sobre os nomes de alguns demonios e suas atuações
No tempo de deus.pubpptx
CARTA DE PAULO AOS FILIPENSES, CAPÍTULO 2
Ad

Similar to Generic or Specific? Making Sensible Software Design Decisions (20)

PDF
Generic or specific? Making sensible software design decisions
PDF
Generic or specific? Making sensible software design decisions
PDF
Generic or specific? Making sensible software design decisions
PDF
JUG CH December 2022 - Generic or specific?
PDF
Generic or specific? Making sensible software design decisions
PDF
Generic or Specific? Making sensible software design decisions
PDF
Generic or specific? Making sensible software design decisions
PPTX
Software Engineering Primer
PPT
Software Engineering Systems Designing end to end
PPTX
Software Design
PPS
Management of Complexity in System Design of Large IT Solutions
PDF
Clean code-v2.2
PDF
Designing Object Oriented Software - lecture slides 2013
PDF
Clean Code .Net Cheetsheets
PPT
香港六合彩
PPT
六合彩|香港六合彩
PPT
香港六合彩-六合彩
PPT
香港六合彩 » SlideShare
PPT
六合彩|香港六合彩
PPT
六合彩,香港六合彩
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
JUG CH December 2022 - Generic or specific?
Generic or specific? Making sensible software design decisions
Generic or Specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
Software Engineering Primer
Software Engineering Systems Designing end to end
Software Design
Management of Complexity in System Design of Large IT Solutions
Clean code-v2.2
Designing Object Oriented Software - lecture slides 2013
Clean Code .Net Cheetsheets
香港六合彩
六合彩|香港六合彩
香港六合彩-六合彩
香港六合彩 » SlideShare
六合彩|香港六合彩
六合彩,香港六合彩
Ad

Recently uploaded (20)

PPTX
module 1-Part 1.pptxdddddddddddddddddddddddddddddddddddd
PPTX
The-Importance-of-School-Sanitation.pptx
PDF
Uptota Investor Deck - Where Africa Meets Blockchain
PDF
Alethe Consulting Corporate Profile and Solution Aproach
PPSX
AI AppSec Threats and Defenses 20250822.ppsx
PDF
The Evolution of Traditional to New Media .pdf
PPTX
KSS ON CYBERSECURITY INCIDENT RESPONSE AND PLANNING MANAGEMENT.pptx
PDF
Containerization lab dddddddddddddddmanual.pdf
PDF
Understand the Gitlab_presentation_task.pdf
PPTX
10.2981-wlb.2004.021Figurewlb3bf00068fig0001.pptx
PPT
12 Things That Make People Trust a Website Instantly
PDF
KEY COB2 UNIT 1: The Business of businessĐH KInh tế TP.HCM
PDF
BIOCHEM CH2 OVERVIEW OF MICROBIOLOGY.pdf
PPTX
Artificial_Intelligence_Basics use in our daily life
DOCX
Memecoinist Update: Best Meme Coins 2025, Trump Meme Coin Predictions, and th...
PDF
Virtual Guard Technology Provider_ Remote Security Service Solutions.pdf
PDF
healthwealthtech4all-blogspot-com-2025-08-top-5-tech-innovations-that-will-ht...
PPTX
Concepts of Object Oriented Programming.
PPTX
Viva Digitally Software-Defined Wide Area Network.pptx
PDF
Computer Networking, Internet, Casting in Network
module 1-Part 1.pptxdddddddddddddddddddddddddddddddddddd
The-Importance-of-School-Sanitation.pptx
Uptota Investor Deck - Where Africa Meets Blockchain
Alethe Consulting Corporate Profile and Solution Aproach
AI AppSec Threats and Defenses 20250822.ppsx
The Evolution of Traditional to New Media .pdf
KSS ON CYBERSECURITY INCIDENT RESPONSE AND PLANNING MANAGEMENT.pptx
Containerization lab dddddddddddddddmanual.pdf
Understand the Gitlab_presentation_task.pdf
10.2981-wlb.2004.021Figurewlb3bf00068fig0001.pptx
12 Things That Make People Trust a Website Instantly
KEY COB2 UNIT 1: The Business of businessĐH KInh tế TP.HCM
BIOCHEM CH2 OVERVIEW OF MICROBIOLOGY.pdf
Artificial_Intelligence_Basics use in our daily life
Memecoinist Update: Best Meme Coins 2025, Trump Meme Coin Predictions, and th...
Virtual Guard Technology Provider_ Remote Security Service Solutions.pdf
healthwealthtech4all-blogspot-com-2025-08-top-5-tech-innovations-that-will-ht...
Concepts of Object Oriented Programming.
Viva Digitally Software-Defined Wide Area Network.pptx
Computer Networking, Internet, Casting in Network

Generic or Specific? Making Sensible Software Design Decisions

  • 1. Generic or specific? Making sensible software design decisions
  • 3. [email protected] Making sensible software design decisions Bert Jan Schrijver @bjschrijver Generic or specific?
  • 4. Bert Jan Schrijver L e t ’ s m e e t @bjschrijver
  • 5. Levels of generic vs specific Tools to help decide Flexibility in software Definitions When & why to go generic Sharing code in an organization Conclusion Outline W h a t ‘ s n e x t ? The cost of generic @bjschrijver
  • 8. • Tailor made for use in a single place • Tailored to a specific problem or scenario • May not be easily adaptable to other situations Specific solution (or design)
  • 9. • More flexible and reusable solution • Solution can be applied to a wide range of problems or scenarios • Generified solution that can be used in more than 1 place Generic solution (or design) Background source: https://filmquarterly.org/2012/07/02/i-robot-what-do-robots-dream-of/
  • 10. • Breaking a system or problem into smaller parts that are easier to understand • Example: Google search Hierarchical decomposition Background source: DALL·E
  • 12. • Kind and degree of interdependence between building blocks of software • Measure of how closely connected two components are • Usually contrasted with cohesion (low coupling -> high cohesion) Coupling Background source: DALL·E
  • 13. • Inheritance • Messages or events • Temporal • Data types • Data • Code / API (binary or source) Types of coupling Background source: DALL·E
  • 14. Be careful with coupling!
  • 15. Generic solution = coupling!
  • 16. The risk of DRY
  • 17. Duplicated code doesn’t hurt until you need to change it.
  • 18. • Should we be prepared for future changes? • Design should be structured to accommodate change • Risk management: risk of wrong decision “Future proof” design Background source: DALL·E
  • 19. About flexibility in software…
  • 20. “Highly specific code is often preferable to sophisticated configuration” - Stefan Tilkov
  • 21. When are we going to talk about generic vs specific? Background source: https://7216-presscdn-0-76-pagely.netdna-ssl.com/wp-content/uploads/2011/12/confused-man-single-good-men.jpg
  • 22. • Code / class level • Manually written vs generated code • Library level • Data level • (Micro)service level • Organisation level Generic vs specific: levels Background source: DALL·E
  • 24. • Do we really need this now? (YAGNI) • The 5 W’s • Time/effort for generic vs specific • Myth of “first time right” • Complexity and scope • The rule of three • Future needs and evolution Tools to help decide
  • 25. • When reusing code, copy it once, and only abstract the third time • Avoid writing the wrong abstraction • It’s easier to make a good abstraction from duplicated code than to refactor the wrong abstraction • "Three strikes and you refactor" The rule of three Background source: https://learntalk.org/en/blog/where-did-the-saying-third-times-the-charm-come-from
  • 26. • First case: Just build it, don’t genericise at all. Solve the problem in front of you (YAGNI) • Second case: Duplicate the original, redesign and extract common behaviour while you change • Third case: examine lessons from first two passes, design a generic solution that will make it easy to add your third case The rule of three Background source: https://learntalk.org/en/blog/where-did-the-saying-third-times-the-charm-come-from
  • 27. • Pass 1: YAGNI / rule of three: as simple and specific as possible • Pass 2: based on solution domain knowledge: is a generic solution less work? • Pass 3: based on problem domain knowledge: is the easiest solution actually correct? • Pass 4: looking at customer behaviour or other non technical considerations, does this change your decision? Design heuristics Background source: DALL·E
  • 28. • Concept from Domain Driven Design • Tool to help decide for generic vs specific • But more about building yourself or not • Subdomains: • Core domain • Supporting subdomain • Generic subdomain Strategic design Background source: GR Stocks on Unsplash
  • 29. • Organizations design systems that mirror their own communication structure • Don’t force a solution that goes against the organisation structure • Be careful to go generic when teams don’t want to work together Conway’s law Background source: DALL·E
  • 30. Conway’s law in action Background source: DALL·E
  • 31. • Another rule of three: building reusable components is 3x as difficult as single use • The price you pay is coupling • Both on code level and people/team level (communication overhead) The cost of a generic solution Background source: DALL·E
  • 32. What if you get it wrong? Photo: Dave Lehl
  • 33. • Efficiency gains of a generic solution are typically clear, but how about: • Onboarding new people • Readability • Coupling The cost of abstractions Background source: Héctor J. Rivas on Unsplash
  • 34. • Writing bad abstractions • Writing unnecessary reusable code • Introducing unnecessary coupling • Maintaining bad abstractions • Hard to see • Hard to understand • Hard to extend The cost of abstractions Background source: Héctor J. Rivas on Unsplash
  • 35. When / why to go generic
  • 36. • ”We’ve always done it like this” • “We don’t want to depend on libraries” • “We need to be future proof” • Because the product owner wants it • Because the architect wants it Bad reasons to go generic
  • 37. • Rule of three checks out • You’re pretty sure you’re going to need it almost everywhere • A library that lots of teams will use • Complex logic or skills that only a couple of people have • Gains are bigger than cost Valid reasons to go generic
  • 38. • Think back about the layers in hierarchical decomposition of a system • Code vs component vs service • Are the considerations for generic vs specific the same on every level? • Risk when getting it wrong is higher when the level is higher • Don’t confuse generification with standardization! Generic vs specific in different scopes Background source: Fernando Gomez on Unsplash
  • 39. Why specific is often faster
  • 49. 49
  • 50. Generic solutions on organization level
  • 51. • Sharing code efficiently at scale is hard • Sharing code at scale means: • Multiple modules that share code • Multiple team members • High rate of change • Little to no loss of individual productivity Sharing code within an organization Source: https://medium.com/@jeffwhelpley/the-problem-with-shared-code-124a20fc3d3b
  • 52. • Challenges: • Refactoring • Versioning • Reviewing • Builds and codebase size - monorepo? Sharing code within an organization Source: https://medium.com/@jeffwhelpley/the-problem-with-shared-code-124a20fc3d3b
  • 53. • Monorepo: 1 large repository for a group of projects (possible all projects) • Good: easy to make changes across projects • Bad: dependencies & build times Monorepositories Background source: DALL·E
  • 54. • Discovery: what code / libraries exist? • Distribution: binary or source dependency? • Import: well defined API’s or chaos? • Versioning, upgrades and lifecycle management • Who maintains it? • Possible approach: inner source culture Considerations on sharing code in an org Source: https://medium.com/@jeffwhelpley/the-problem-with-shared-code-124a20fc3d3b, background source: Klara Kulikova on Unsplash
  • 56. • Consider: • YAGNI / Rule of three / 5 W’s • Cost of generic • Scope / level • Conway’s law • Organization Generic or specific?
  • 58. A program that works perfectly but is impossible to change will become useless. A program that does not work but is easy to change will become and remain useful continuously. Source: Clean Architecture, Robert C. Martin
  • 60. NOW GO KICK SOME ASS!
  • 62. Thanks for your time. Got feedback? Tweet it! All pictures belong to their respective authors @bjschrijver