SlideShare ist ein Scribd-Unternehmen logo
1 von 57
Downloaden Sie, um offline zu lesen
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
• 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
• Manual 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
Exception handling
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
NOW GO KICK SOME ASS!
Questions?
@bjschrijver
Thanks for your time.
Got feedback? Tweet it!
All pictures belong
to their respective
authors
@bjschrijver

Weitere ähnliche Inhalte

Ähnlich wie Generic or specific? Making sensible software design decisions

Agile Software Development.ppt
Agile Software Development.pptAgile Software Development.ppt
Agile Software Development.pptabdulwehab2
 
Neo4j Theory and Practice - Tareq Abedrabbo @ GraphConnect London 2013
Neo4j Theory and Practice - Tareq Abedrabbo @ GraphConnect London 2013Neo4j Theory and Practice - Tareq Abedrabbo @ GraphConnect London 2013
Neo4j Theory and Practice - Tareq Abedrabbo @ GraphConnect London 2013Neo4j
 
Online TechTalk  "Patterns in Embedded SW Design"
Online TechTalk  "Patterns in Embedded SW Design"Online TechTalk  "Patterns in Embedded SW Design"
Online TechTalk  "Patterns in Embedded SW Design"GlobalLogic Ukraine
 
Excavating the knowledge of our ancestors
Excavating the knowledge of our ancestorsExcavating the knowledge of our ancestors
Excavating the knowledge of our ancestorsUwe Friedrichsen
 
Cleaning Code - Tools and Techniques for Large Legacy Projects
Cleaning Code - Tools and Techniques for Large Legacy ProjectsCleaning Code - Tools and Techniques for Large Legacy Projects
Cleaning Code - Tools and Techniques for Large Legacy ProjectsMike Long
 
Software design principles
Software design principlesSoftware design principles
Software design principlesMd.Mojibul Hoque
 
The 360 Developer
The 360 DeveloperThe 360 Developer
The 360 Developerenteritos
 
Module 2 design patterns-2
Module 2   design patterns-2Module 2   design patterns-2
Module 2 design patterns-2Ankit Dubey
 
Technologies for startup
Technologies for startupTechnologies for startup
Technologies for startupDzung Nguyen
 
It's XP Stupid (2019)
It's XP Stupid (2019)It's XP Stupid (2019)
It's XP Stupid (2019)Mike Harris
 
Capability Building for Cyber Defense: Software Walk through and Screening
Capability Building for Cyber Defense: Software Walk through and Screening Capability Building for Cyber Defense: Software Walk through and Screening
Capability Building for Cyber Defense: Software Walk through and Screening Maven Logix
 
Design Patterns - General Introduction
Design Patterns - General IntroductionDesign Patterns - General Introduction
Design Patterns - General IntroductionAsma CHERIF
 
An Introduction To Software Development - Implementation
An Introduction To Software Development - ImplementationAn Introduction To Software Development - Implementation
An Introduction To Software Development - ImplementationBlue Elephant Consulting
 
Devconf 2011 - PHP - How Yii framework is developed
Devconf 2011 - PHP - How Yii framework is developedDevconf 2011 - PHP - How Yii framework is developed
Devconf 2011 - PHP - How Yii framework is developedAlexander Makarov
 

Ähnlich wie Generic or specific? Making sensible software design decisions (20)

Agile Software Development.ppt
Agile Software Development.pptAgile Software Development.ppt
Agile Software Development.ppt
 
Neo4j Theory and Practice - Tareq Abedrabbo @ GraphConnect London 2013
Neo4j Theory and Practice - Tareq Abedrabbo @ GraphConnect London 2013Neo4j Theory and Practice - Tareq Abedrabbo @ GraphConnect London 2013
Neo4j Theory and Practice - Tareq Abedrabbo @ GraphConnect London 2013
 
Online TechTalk  "Patterns in Embedded SW Design"
Online TechTalk  "Patterns in Embedded SW Design"Online TechTalk  "Patterns in Embedded SW Design"
Online TechTalk  "Patterns in Embedded SW Design"
 
Excavating the knowledge of our ancestors
Excavating the knowledge of our ancestorsExcavating the knowledge of our ancestors
Excavating the knowledge of our ancestors
 
Cleaning Code - Tools and Techniques for Large Legacy Projects
Cleaning Code - Tools and Techniques for Large Legacy ProjectsCleaning Code - Tools and Techniques for Large Legacy Projects
Cleaning Code - Tools and Techniques for Large Legacy Projects
 
Software design principles
Software design principlesSoftware design principles
Software design principles
 
Code quality
Code quality Code quality
Code quality
 
The 360 Developer
The 360 DeveloperThe 360 Developer
The 360 Developer
 
It's XP, Stupid
It's XP, StupidIt's XP, Stupid
It's XP, Stupid
 
Module 2 design patterns-2
Module 2   design patterns-2Module 2   design patterns-2
Module 2 design patterns-2
 
Technologies for startup
Technologies for startupTechnologies for startup
Technologies for startup
 
It's XP Stupid (2019)
It's XP Stupid (2019)It's XP Stupid (2019)
It's XP Stupid (2019)
 
Zend Di in ZF 2.0
Zend Di in ZF 2.0Zend Di in ZF 2.0
Zend Di in ZF 2.0
 
Capability Building for Cyber Defense: Software Walk through and Screening
Capability Building for Cyber Defense: Software Walk through and Screening Capability Building for Cyber Defense: Software Walk through and Screening
Capability Building for Cyber Defense: Software Walk through and Screening
 
Agile Technical Leadership
Agile Technical LeadershipAgile Technical Leadership
Agile Technical Leadership
 
Design Patterns - General Introduction
Design Patterns - General IntroductionDesign Patterns - General Introduction
Design Patterns - General Introduction
 
An Introduction To Software Development - Implementation
An Introduction To Software Development - ImplementationAn Introduction To Software Development - Implementation
An Introduction To Software Development - Implementation
 
Devconf 2011 - PHP - How Yii framework is developed
Devconf 2011 - PHP - How Yii framework is developedDevconf 2011 - PHP - How Yii framework is developed
Devconf 2011 - PHP - How Yii framework is developed
 
Why You're A Bad PHP Programmer
Why You're A Bad PHP ProgrammerWhy You're A Bad PHP Programmer
Why You're A Bad PHP Programmer
 
Code Smells
Code SmellsCode Smells
Code Smells
 

Kürzlich hochgeladen

Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 

Kürzlich hochgeladen (20)

Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 

Generic or specific? Making sensible software design decisions

  • 1. bertjan@openvalue.eu Making sensible software design decisions Bert Jan Schrijver @bjschrijver Generic or specific?
  • 2. Bert Jan Schrijver L e t ’ s m e e t @bjschrijver
  • 3. 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
  • 6. • 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)
  • 7. • 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/
  • 8. • Breaking a system or problem into smaller parts that are easier to understand • Example: Google search Hierarchical decomposition Background source: DALL·E
  • 10. • 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
  • 11. • Inheritance • Messages or events • Temporal • Data types • Data • Code / API (binary or source) Types of coupling Background source: DALL·E
  • 12. Be careful with coupling!
  • 13. Generic solution = coupling!
  • 14. The risk of DRY
  • 15. • 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
  • 16. About flexibility in software…
  • 17. “Highly specific code is often preferable to sophisticated configuration” - Stefan Tilkov
  • 18. 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
  • 19. • Code / class level • Manual vs generated code • Library level • Data level • (Micro)service level • Organisation level Generic vs specific: levels Background source: DALL·E
  • 21. • 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
  • 22. • 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
  • 23. • 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
  • 24. • 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
  • 25. • 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
  • 26. • 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
  • 27. Conway’s law in action Background source: DALL·E
  • 28. • 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
  • 29. What if you get it wrong? Photo: Dave Lehl
  • 30. • 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
  • 31. • 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
  • 32. When / why to go generic
  • 33. • ”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
  • 34. • 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
  • 35. • 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
  • 36. Why specific is often faster
  • 39.
  • 40.
  • 41.
  • 42.
  • 44.
  • 45. Generic solutions on organization level
  • 46. • 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
  • 47. • 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
  • 48. • 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
  • 49. • 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
  • 51. • Consider: • YAGNI / Rule of three / 5 W’s • Cost of generic • Scope / level • Conway’s law • Organization Generic or specific?
  • 53. 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
  • 54.
  • 55. NOW GO KICK SOME ASS!
  • 57. Thanks for your time. Got feedback? Tweet it! All pictures belong to their respective authors @bjschrijver