SlideShare a Scribd company logo
Thoughtful Software Design
Agenda
 Background
 Orienteering
 Basic Principles
 From Legacy to Thoughtful Design
 Tearing It Apart
 Q & A
 Great Reads
Background
Software Design
is the process of structuring a solution
into components, abstractions and interactions,
with the goal of effectively coping with changes.
What Is Software Design?
“Modeling and Design are often
the quickest path to the actual goal”
- Eric Evans
Motivation
Maintainability
Compatibility
Reliability
Modularity
Extensibility
Robustness
Reusability
Leanness
Readability
Testability
Reversibility
Predictability
Performance
Transparency
Security
Consistency
Usability
Portability
Scalability
Simplicity
Independence
Contextual Tradeoffs
Orienteering
2. How do I use it?1. How do I change it?
Think Of:
Extensibility
Maintainability
Implementation
Coupling
Think Of:
Clarity
Predictability
Intents
Cohesion
Designer Mindsets
How much of one module must be known in order to understand
another module?
The more that we must know of module B in order to understand
module A, the more closely connected A is to B.
The act of linking
two things together.
The degree to which software components
are dependent upon each other.
Coupling
Coupling
Illustrations from the book: Dependency Injection in NET – Mark Seemann
Tight Lose
Are your components attached to the wall?
The action or fact of forming
a united whole.
The measure of how strongly-
related and focused the various
responsibilities of a software
component are.
The cohesion of each component, considered in isolation, is
determined by how tightly bound or related its internal elements are to
one another.
Cohesion
Cohesion
Low Cohesion Examples
Abstraction is an emphasis on the idea,
qualities and properties rather than the
particulars (a suppression of detail)
Abstraction & Generalization
E. g., multiple implementations complying with one interface
Generalization is a broadening of
application to encompass a larger domain
of objects of the same or different type
E. g., one implementation can process multiple types (Generics)
Abstraction & Generalization
We now need to handle a
Toy Dog that acts like a
normal dog but has a special
method: ChangeBatteries()
Requirement Change
Mistake #1:
Ruining The Abstraction
Mistake #2:
Ruining The Generalization
Adding ChangeBatteries() to
the IDog interface
How would you handle it?
The inclusion of one thing within another thing so
that the included thing is not apparent
 Protecting state integrity by preventing users from
setting the internal data of the component into an
invalid or inconsistent state.
 Exposing a solution to a problem without requiring the
consumer to fully understand the problem domain.
Encapsulation
Encapsulation
Should we add these sorting methods
to the List class?
Should a car allow the driver to
control the pressure of the fuel injection?
A layer represents a well-encapsulated group of
reusable components perform a common
architectural function within an application
Layered Architecture
Layered Architecture
Layer N+1
Layer N
Data Only
Well-Isolated
Layers
Layer N+1
Layer N
Business Objects
Implementation Leaking
Layers
Example:
Content/Common Coupling
(strong)
Data Structure/Data Coupling (weak)
Basic Principles
A class should have only one reason to change
Gather together the things that change for the
same reasons. Separate those things that change
for different reasons
Single Responsibility Principle
Single Responsibility Principle
Example:
Accounting
Infrastructure
Operations
Example From: The Single Responsibility Principle – Robert C. Martin
https://blog.8thlight.com/uncle-bob/2014/05/08/SingleReponsibilityPrinciple.html
 Fault-Safe, constrained API
 Commands Queries Separation
 Referential Transparency / Immutability
 Design By Contract
 Dependency Injection
 Null Prevention Patterns, etc.
A component of a system should behave in a
manner consistent with how users of that
component are likely to expect it to behave
Principle of Least Astonishment
Principle of Least Astonishment
reporting.PrintReportA()
reporting.PrintReportB()
Example:
reporting.PrintReportB()
reporting.PrintReportA()
Print report A and then
Report B . It works Fine.
DB Connection Error!
But Why?
Changed to print report B
before report A
A database connection is opened at the
Beginning of PrintReportA and closed
at the end of PrintReportB
Design By Contract
Pre-conditions
Post-conditions
(Class) Invariants
Define formal, precise and verifiable
interface specifications for software
components, which extend the ordinary
definition of abstract data types with pre-
conditions, post-conditions and invariants.
Assert conditions that must be satisfied prior to the execution of a
method. The responsibility is on the caller.
Assert for conditions that must be satisfied after to the execution of a
method. The responsibility is on the method called.
Add assertions for conditions that must be satisfied before and after the
execution of any public method. The responsibility is on the class used.
Design By Contract
Example:
A.K.A. Law Of Demeter
 Each component should have only limited knowledge
about other components: only components "closely"
related to the current component
 Each component should only talk to its friends:
don't talk to strangers.
 Only talk to your immediate friends
The Principle of Least Knowledge
A.K.A. Law Of Demeter
The Principle of Least Knowledge
A B C
ask for to look for
Violation!
B is just a middleman,
A only needs C
Solution 1: Get Rid Of B Solution 2: Encapsulate C
A C
ask for
A
ask for
B C
C is a stranger to A
A.K.A. Law Of Demeter
The Principle of Least Knowledge
Don’t look for things Ask for what you need
Example From: The Clean Code Talks - Don't Look For Things! – Misko Hevery
https://www.youtube.com/watch?v=RlfLCWKxHJ0
From Legacy To Thoughtful Design
Load & Save an Invoice
Add & Remove Invoice Items
Reschedule the Invoice Delivery Date
Void the Invoice
Calculate Invoice Totals & Taxes
Export Invoice to a File
Print Invoice
Email Invoice
Features On The Menu
Legacy Invoice Interface
Tearing It Apart
Add & Remove Invoice Items
Reschedule the Invoice Delivery Date
Void the Invoice
Calculate Invoice Totals & Taxes
Load & Save an Invoice (DB)
Export Invoice to a File
Print Invoice
Email Invoice
Persistence
Business
Reporting
Separating Concerns
Should be immutable!
IEnumerable
Protecting Data
Add & Remove Invoice Items
Reschedule the Invoice
Void the Invoice
Business
Calculate Invoice Totals & Taxes
As an invoice user I want to...
I don't want to deal with it...
Why would we
expose an internal
calculation?
Encapsulating Methods
Does not belong here
Cohesion
Commands
do not return values!
Command Query Separation
Ask,
don't look
for things!
Generic
reschedule
for any day
Principle Of Least Knowledge
Legacy
Invoice
Model
Invoice
Data
Model
Invoice
Domain
Model
Used By
Used By
- Persistence
- View Models & Reporting
- Business Logic & Events
Business Logic
should not leak
into other layers
Exposes
Data
Exposes
Business
Operations
Isolating Layers
Any change
produces a
new instance
Can extract
Data Model
when needed
Immutability
Questions?
Structured Design: Fundamentals of a Discipline of
Computer Program and Systems Design
Edward Yourdon, Larry L. Constantine
Principles Of Object Oriented Design
http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod
Robert C. Martin
Refactoring: Improving the Design of Existing Code
Martin Fowler
Design Patterns: Elements of Reusable Object-Oriented Software
Eric Gamma, Richard Helm, Ralph Johnson, John Vlissides
Clean Code: A Handbook of Agile Software Craftsmanship
Robert C. Martin
The Art of UNIX Programming
Eric S. Raymond
The Pragmatic Programmer: From Journeyman to Master
Andrew Hunt, David Thomas
Domain-Driven Design: Tackling Complexity in the Heart of Software
Eric Evans
Great Reads
giovanni.scerra@afsi.com
My Contact Info:
https://www.linkedin.com/in/giovanniscerra

More Related Content

PDF
Getting Started With Testing
PDF
Getting Started With QA Automation
PPTX
Improving Estimates
PDF
Clean Software Design: The Practices to Make The Design Simple
PPTX
Bdd masterclass
PPT
Agile Open 2009 Tdd And Architecture Influences
PDF
Grokking Techtalk: Problem solving for sw engineers
PPTX
2015.01.09 - Writing Modern Applications for Mobile and Web
Getting Started With Testing
Getting Started With QA Automation
Improving Estimates
Clean Software Design: The Practices to Make The Design Simple
Bdd masterclass
Agile Open 2009 Tdd And Architecture Influences
Grokking Techtalk: Problem solving for sw engineers
2015.01.09 - Writing Modern Applications for Mobile and Web

What's hot (18)

PPTX
01 introduction to entity framework
PPTX
Dependency Injection Pattern
DOCX
Interview questions
PDF
Black box
PDF
BlackBox.pdf
PPTX
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
PDF
Manual QA Testing Interview Questions From H2KInfosys
PDF
Software design.edited (1)
PDF
Istqb interview questions By H2KInfosys
PPT
Tutorial of web application load testing in selinium
PPTX
Importance of the quality of code
PDF
Approaching ATDD/BDD
PDF
Fighting with Waste Driven Development - XP Days Ukraine 2017
DOC
Manual Testing.
PDF
Code quality as a built-in process
PDF
React Interview Questions and Answers | React Tutorial | React Redux Online T...
DOC
Manual testing interview question by INFOTECH
PDF
Unwritten Manual for Pair Programming
01 introduction to entity framework
Dependency Injection Pattern
Interview questions
Black box
BlackBox.pdf
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
Manual QA Testing Interview Questions From H2KInfosys
Software design.edited (1)
Istqb interview questions By H2KInfosys
Tutorial of web application load testing in selinium
Importance of the quality of code
Approaching ATDD/BDD
Fighting with Waste Driven Development - XP Days Ukraine 2017
Manual Testing.
Code quality as a built-in process
React Interview Questions and Answers | React Tutorial | React Redux Online T...
Manual testing interview question by INFOTECH
Unwritten Manual for Pair Programming
Ad

Similar to Thoughtful Software Design (20)

PPTX
Patterns of Assigning Responsibilities
PPT
Oops Concepts
PPT
Best practices for agile design
PPTX
.NET Architecture for Enterprises
PPTX
Design Principles
PDF
Software design - Write solid software with the ideal chalk
PPTX
C:\Fakepath\Combating Software Entropy 2
PPTX
C:\Fakepath\Combating Software Entropy 2
PPT
Arch factory - Agile Design: Best Practices
PPTX
OOP -interface and objects.pptx
PDF
Structured Software Design
PPTX
The good, the bad and the SOLID
PDF
Software design principles - jinal desai
PDF
Are You a SOLID Coder?
PPTX
06 fse design
PPTX
Software Design
PPTX
Improving the Quality of Existing Software
PPTX
TEST PPT
PPTX
Object Oriented Design SOLID Principles
PPTX
Improving The Quality of Existing Software
Patterns of Assigning Responsibilities
Oops Concepts
Best practices for agile design
.NET Architecture for Enterprises
Design Principles
Software design - Write solid software with the ideal chalk
C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2
Arch factory - Agile Design: Best Practices
OOP -interface and objects.pptx
Structured Software Design
The good, the bad and the SOLID
Software design principles - jinal desai
Are You a SOLID Coder?
06 fse design
Software Design
Improving the Quality of Existing Software
TEST PPT
Object Oriented Design SOLID Principles
Improving The Quality of Existing Software
Ad

Recently uploaded (20)

PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
System and Network Administraation Chapter 3
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
Online Work Permit System for Fast Permit Processing
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
ISO 45001 Occupational Health and Safety Management System
PDF
System and Network Administration Chapter 2
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
top salesforce developer skills in 2025.pdf
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Softaken Excel to vCard Converter Software.pdf
How to Choose the Right IT Partner for Your Business in Malaysia
System and Network Administraation Chapter 3
2025 Textile ERP Trends: SAP, Odoo & Oracle
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Design an Analysis of Algorithms II-SECS-1021-03
Wondershare Filmora 15 Crack With Activation Key [2025
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Operating system designcfffgfgggggggvggggggggg
Design an Analysis of Algorithms I-SECS-1021-03
Navsoft: AI-Powered Business Solutions & Custom Software Development
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Online Work Permit System for Fast Permit Processing
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
ISO 45001 Occupational Health and Safety Management System
System and Network Administration Chapter 2
Odoo Companies in India – Driving Business Transformation.pdf
top salesforce developer skills in 2025.pdf
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Which alternative to Crystal Reports is best for small or large businesses.pdf
Softaken Excel to vCard Converter Software.pdf

Thoughtful Software Design

  • 1. Thoughtful Software Design Agenda  Background  Orienteering  Basic Principles  From Legacy to Thoughtful Design  Tearing It Apart  Q & A  Great Reads
  • 3. Software Design is the process of structuring a solution into components, abstractions and interactions, with the goal of effectively coping with changes. What Is Software Design?
  • 4. “Modeling and Design are often the quickest path to the actual goal” - Eric Evans Motivation
  • 7. 2. How do I use it?1. How do I change it? Think Of: Extensibility Maintainability Implementation Coupling Think Of: Clarity Predictability Intents Cohesion Designer Mindsets
  • 8. How much of one module must be known in order to understand another module? The more that we must know of module B in order to understand module A, the more closely connected A is to B. The act of linking two things together. The degree to which software components are dependent upon each other. Coupling
  • 9. Coupling Illustrations from the book: Dependency Injection in NET – Mark Seemann Tight Lose Are your components attached to the wall?
  • 10. The action or fact of forming a united whole. The measure of how strongly- related and focused the various responsibilities of a software component are. The cohesion of each component, considered in isolation, is determined by how tightly bound or related its internal elements are to one another. Cohesion
  • 12. Abstraction is an emphasis on the idea, qualities and properties rather than the particulars (a suppression of detail) Abstraction & Generalization E. g., multiple implementations complying with one interface Generalization is a broadening of application to encompass a larger domain of objects of the same or different type E. g., one implementation can process multiple types (Generics)
  • 13. Abstraction & Generalization We now need to handle a Toy Dog that acts like a normal dog but has a special method: ChangeBatteries() Requirement Change Mistake #1: Ruining The Abstraction Mistake #2: Ruining The Generalization Adding ChangeBatteries() to the IDog interface How would you handle it?
  • 14. The inclusion of one thing within another thing so that the included thing is not apparent  Protecting state integrity by preventing users from setting the internal data of the component into an invalid or inconsistent state.  Exposing a solution to a problem without requiring the consumer to fully understand the problem domain. Encapsulation
  • 15. Encapsulation Should we add these sorting methods to the List class? Should a car allow the driver to control the pressure of the fuel injection?
  • 16. A layer represents a well-encapsulated group of reusable components perform a common architectural function within an application Layered Architecture
  • 17. Layered Architecture Layer N+1 Layer N Data Only Well-Isolated Layers Layer N+1 Layer N Business Objects Implementation Leaking Layers Example: Content/Common Coupling (strong) Data Structure/Data Coupling (weak)
  • 19. A class should have only one reason to change Gather together the things that change for the same reasons. Separate those things that change for different reasons Single Responsibility Principle
  • 20. Single Responsibility Principle Example: Accounting Infrastructure Operations Example From: The Single Responsibility Principle – Robert C. Martin https://blog.8thlight.com/uncle-bob/2014/05/08/SingleReponsibilityPrinciple.html
  • 21.  Fault-Safe, constrained API  Commands Queries Separation  Referential Transparency / Immutability  Design By Contract  Dependency Injection  Null Prevention Patterns, etc. A component of a system should behave in a manner consistent with how users of that component are likely to expect it to behave Principle of Least Astonishment
  • 22. Principle of Least Astonishment reporting.PrintReportA() reporting.PrintReportB() Example: reporting.PrintReportB() reporting.PrintReportA() Print report A and then Report B . It works Fine. DB Connection Error! But Why? Changed to print report B before report A A database connection is opened at the Beginning of PrintReportA and closed at the end of PrintReportB
  • 23. Design By Contract Pre-conditions Post-conditions (Class) Invariants Define formal, precise and verifiable interface specifications for software components, which extend the ordinary definition of abstract data types with pre- conditions, post-conditions and invariants. Assert conditions that must be satisfied prior to the execution of a method. The responsibility is on the caller. Assert for conditions that must be satisfied after to the execution of a method. The responsibility is on the method called. Add assertions for conditions that must be satisfied before and after the execution of any public method. The responsibility is on the class used.
  • 25. A.K.A. Law Of Demeter  Each component should have only limited knowledge about other components: only components "closely" related to the current component  Each component should only talk to its friends: don't talk to strangers.  Only talk to your immediate friends The Principle of Least Knowledge
  • 26. A.K.A. Law Of Demeter The Principle of Least Knowledge A B C ask for to look for Violation! B is just a middleman, A only needs C Solution 1: Get Rid Of B Solution 2: Encapsulate C A C ask for A ask for B C C is a stranger to A
  • 27. A.K.A. Law Of Demeter The Principle of Least Knowledge Don’t look for things Ask for what you need Example From: The Clean Code Talks - Don't Look For Things! – Misko Hevery https://www.youtube.com/watch?v=RlfLCWKxHJ0
  • 28. From Legacy To Thoughtful Design
  • 29. Load & Save an Invoice Add & Remove Invoice Items Reschedule the Invoice Delivery Date Void the Invoice Calculate Invoice Totals & Taxes Export Invoice to a File Print Invoice Email Invoice Features On The Menu
  • 32. Add & Remove Invoice Items Reschedule the Invoice Delivery Date Void the Invoice Calculate Invoice Totals & Taxes Load & Save an Invoice (DB) Export Invoice to a File Print Invoice Email Invoice Persistence Business Reporting Separating Concerns
  • 34. Add & Remove Invoice Items Reschedule the Invoice Void the Invoice Business Calculate Invoice Totals & Taxes As an invoice user I want to... I don't want to deal with it... Why would we expose an internal calculation? Encapsulating Methods
  • 35. Does not belong here Cohesion
  • 36. Commands do not return values! Command Query Separation
  • 37. Ask, don't look for things! Generic reschedule for any day Principle Of Least Knowledge
  • 38. Legacy Invoice Model Invoice Data Model Invoice Domain Model Used By Used By - Persistence - View Models & Reporting - Business Logic & Events Business Logic should not leak into other layers Exposes Data Exposes Business Operations Isolating Layers
  • 39. Any change produces a new instance Can extract Data Model when needed Immutability
  • 41. Structured Design: Fundamentals of a Discipline of Computer Program and Systems Design Edward Yourdon, Larry L. Constantine Principles Of Object Oriented Design http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod Robert C. Martin Refactoring: Improving the Design of Existing Code Martin Fowler Design Patterns: Elements of Reusable Object-Oriented Software Eric Gamma, Richard Helm, Ralph Johnson, John Vlissides Clean Code: A Handbook of Agile Software Craftsmanship Robert C. Martin The Art of UNIX Programming Eric S. Raymond The Pragmatic Programmer: From Journeyman to Master Andrew Hunt, David Thomas Domain-Driven Design: Tackling Complexity in the Heart of Software Eric Evans Great Reads