SlideShare une entreprise Scribd logo
1  sur  39
Crafted Design
Sandro Mancuso
@sandromancuso
http://leanpub.com/socra
 What is this application about?
 What are the main concepts?
 What does this application do?
 What are the main features?
 Where do I need to change?
 Where do I put a new feature?
 Looking from above, I can’t see what the application does
or is about
 Architectural and design concepts mixed with domain
 Badly structured packages/namespaces
 I don’t know where to start
 Classes and methods are too low level
Example: Layered structure
What does this application do? What is it about?
Example: Layered-domain structure
Books and Users. Cool, but what does this application do?
Example: MVC structure
Awesome. It’s a web application. So?
MVC & MVC Variations
• MVC (Smalltalk 76/80)
• MVC (general concept – 1988)
• Three-Tier Architecture (Presentation, Logic, Data)
• MVC (Model 1/Model 2)
• Model View Adapter (MVA)
• Model View Presenter (MVP)
• Model View ViewModel (MVVM)
• Presentation-Abstraction-Control (PAC)
• ….
MVC
used
badly
Anaemic
Domain
Fat
Controllers
Coupling
with MVC
framework
MVC & MVC Variations
They are all wrong. But they are also right. It all depends on the ‘V’iew.
Views impact MVC structure
Depending on the view technology, Views and Controllers
responsibility becomes more/less coupled or blurred.
 Web applications
 Single-page AJAX applications with stateless backend
 Console-based applications
 Desktop applications
 Games
 Mobile / tablets
 External systems (talking via Queues / Webservices)
However, the model should remain unchanged.
MVC – A Macro Organisational Pattern
Model
V C M
Delivery
Mechanism
“Model” is overloaded and confusing
 Model (M in MVC)
 Domain Model (DDD)
 View Model
 Data Model
 Entities & Active Record
 and other artificial definitions from MVC frameworks
 Associated with the persistence mechanism?
M => Domain Model (DDD)
Domain Model combines state and behaviour,
with more focus on the latter.
DDD define a few building blocks to your domain:
 Entities
 Value Objects
 Factories
 Repositories
 Services
 Application
 Domain
 Infrastructure
 Aggregates
<< Web app >>
Embedded Domain Model
Model
V C DM
Delivery
Mechanism
Infrastructure Infrastructure
DB
Queue
Deployable Domain Model
Delivery
Mechanisms
<< external system >>
<< mobile app >>
DB
<< deployable app >>
Model
Infrastructure
DM
<<W/S>>
<<W/S>>
Event-Driven Domain Model
Delivery
Mechanisms DB
Queue
<< external app 2 >>
<< external app 1 >> << deployable app >>
Model
Infrastructure
DMQueue
<<event 1>>
<<event 2>>
Domain Model – Responsibilities
UC = Use Case, DS = Domain Service, S = Infra. Service, R = Repository
Model
UC 1
R 3
DS 1
DS 3
R 1
S
Infrastructure Impl
DM
DS 2
Impl
UC 2
<< web app >>
Repositories (not DAOs)
Model
<<repository>>
Library
<<repository>>
Users
Infrastructure
<<Mongo>>
Books
Domain Model
<<Oracle>>
Users
“A Repository represents all objects of a certain type as a conceptual set.
It acts like a collection, except with more elaborate querying capability.”
~ Eric Evans
Command & Query Use Cases
<< web app >>
Model
R
DS
<<Write Model>>
UC
Model
<<Read Model>>
UC
DB
DB
Queue <<domain events>>
So, how does the app structure look like?
Web project responsibility
Control flow (invoke use cases)
JSON / XML parsers or converters
Page Objects, validators, etc
Static files
Core responsibility (simple project)
Tells what the system is about
Tells what the system does
Core responsibility (bigger project)
Epic / Theme
Epic / Theme
Epic / Theme
Related domain concepts
What is inside model packages?
Aggregate root (entity)
Repository
Entity (part of Book aggregate)
Domain Service
Value Object (part of Book aggregate)
Part of aggregate behaviour
Repository
Value Object (part of User aggregate)
Aggregate root (entity)
Domain Service
What is inside infrastructure?
Interfaces defined by the domain.
Dependency Inversion Principle (DIP)
CreditCardProcessor implementations
Repository implementations
Domain Model collaborations guideline
C
UC 1
UC 2
DS 1
DS 3
DS 2
R 3
R 1
cl
cl
cl
cl
C = Controller, UC = Use Case, DS = Domain Service, R = Repository, cl = class
Class responsibility
C UC DS R
cl
DB
Input Output
End of code branch
Produces the output
End of flow
First to handle input
Start of the flow
Execution Flow
 Closer to the input: Control flow, higher level abstraction, detailed work is delegated
(e.g. ProcessTrade (UC), MakePayment (UC)) — More suitable for Outside-In TDD
(mockist).
 Closer to the output / end of branch: Specific and detailed behaviour, no delegation,
lower level abstraction (e.g. Parse XML (Parser), Create User (Repository))
Domain Model entry
point Domain Concept
entry point
Defining testing strategies and boundaries
• Unit
• Integration
• Acceptance
• Journey
• Black box
• Component
• System
• Functional
• Alpha
• Beta
• Conformance
• …
Types of tests
Testing strategies: User Journey
Model
UC 1
DM
UC 2
<< web app >>
UC 1
UC 2
Tests the journey a user will have to do something
useful in the system
Application is tested as a black box normally using
a BDD framework
Use cases are facked. We just want to know if the
application presents the user with the correct
journey
Designed according to User Stories
and Features
<<fake>>
<<fake>>
Infrastructure Impl
Testing strategies: Acceptance (Action / Behavioural)
UC DS 1
<<mock>>
RDS 2 R
Tests a behaviour (action) provided by the system
Use Case is the entry point
and all external dependencies
are stubbed
Domain Model
Normally tested using a BDD
framework
Testing strategies: Integration
Tests the classes at the system boundaries
Infrastructure Impl
UC DS 1
<<mock>>
RDS 2 R
Domain Model
Normally done using an in-
memory Database using a unit
testing framework
Testing strategies: Unit (Class level)
Unit test at class/method level
Infrastructure Impl
UC DS 1
RRDS 2
Domain Model
DS 1
DS 2
All collaborators are
mocked / stubbed
(spies)
Testing strategies: End-to-End
Model
UC 1
R 3
DS 1
DS 3
R 1
S
Infrastructure Impl
DM
DS 2
Impl
UC 2
<< web app >>
Full application deployed
Uses BDD framework, accessing a testing database and
fake external dependencies
Very few tests at this level, just to make sure
application is wired properly
Outside-In vs. Classic TDD
 The closer to the input a class is, the more flow control and delegation it does.
 The closer to the output a class is, the more specific and less delegation it does.
Using Outside-in TDD starting from Controllers and/or Use Cases.
Model
UC 1
R 3
DS 1
DS 3
R 1
S
Infrastructure Impl
DM
DS 2
Impl
UC 2
<< web app >>
Answering the two original questions
 What is the application about? (main concepts)
 What does the application do? (main features)
Expressed by nouns
Expressed by verbs
(Actions)
Thank You
http://leanpub.com/socra
@sandromancuso

Contenu connexe

Similaire à Crafted Design - GeeCON 2014

Introduction to SOFTWARE ARCHITECTURE
Introduction to SOFTWARE ARCHITECTUREIntroduction to SOFTWARE ARCHITECTURE
Introduction to SOFTWARE ARCHITECTUREIvano Malavolta
 
Refreshing Domain Driven Design
Refreshing Domain Driven DesignRefreshing Domain Driven Design
Refreshing Domain Driven DesignAndré Borgonovo
 
Onion Architecture with S#arp
Onion Architecture with S#arpOnion Architecture with S#arp
Onion Architecture with S#arpGary Pedretti
 
[2015/2016] Introduction to software architecture
[2015/2016] Introduction to software architecture[2015/2016] Introduction to software architecture
[2015/2016] Introduction to software architectureIvano Malavolta
 
The Magic Of Application Lifecycle Management In Vs Public
The Magic Of Application Lifecycle Management In Vs PublicThe Magic Of Application Lifecycle Management In Vs Public
The Magic Of Application Lifecycle Management In Vs PublicDavid Solivan
 
Clean architecture with asp.net core
Clean architecture with asp.net coreClean architecture with asp.net core
Clean architecture with asp.net coreSam Nasr, MCSA, MVP
 
Modern Database Development Oow2008 Lucas Jellema
Modern Database Development Oow2008 Lucas JellemaModern Database Development Oow2008 Lucas Jellema
Modern Database Development Oow2008 Lucas JellemaLucas Jellema
 
Action-Domain-Responder: A Web-Specific Refinement of Model-View-Controller
Action-Domain-Responder: A Web-Specific Refinement of Model-View-ControllerAction-Domain-Responder: A Web-Specific Refinement of Model-View-Controller
Action-Domain-Responder: A Web-Specific Refinement of Model-View-ControllerPaul Jones
 
CQRS: A More Effective Way of Writing the Same Applications
CQRS: A More Effective Way of Writing the Same ApplicationsCQRS: A More Effective Way of Writing the Same Applications
CQRS: A More Effective Way of Writing the Same ApplicationsCodeFest
 
MVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVCMVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVCAnton Krasnoshchok
 
DDS Advanced Tutorial - OMG June 2013 Berlin Meeting
DDS Advanced Tutorial - OMG June 2013 Berlin MeetingDDS Advanced Tutorial - OMG June 2013 Berlin Meeting
DDS Advanced Tutorial - OMG June 2013 Berlin MeetingJaime Martin Losa
 
Vertical Slicing Architectures
Vertical Slicing ArchitecturesVertical Slicing Architectures
Vertical Slicing ArchitecturesVictor Rentea
 
DQ Product Usage Methodology Highlights_v6_ltd
DQ Product Usage Methodology Highlights_v6_ltdDQ Product Usage Methodology Highlights_v6_ltd
DQ Product Usage Methodology Highlights_v6_ltdDigendra Vir Singh (DV)
 
Multi-tenancy with Rails
Multi-tenancy with RailsMulti-tenancy with Rails
Multi-tenancy with RailsPaul Gallagher
 

Similaire à Crafted Design - GeeCON 2014 (20)

Introduction to SOFTWARE ARCHITECTURE
Introduction to SOFTWARE ARCHITECTUREIntroduction to SOFTWARE ARCHITECTURE
Introduction to SOFTWARE ARCHITECTURE
 
Refreshing Domain Driven Design
Refreshing Domain Driven DesignRefreshing Domain Driven Design
Refreshing Domain Driven Design
 
Onion Architecture with S#arp
Onion Architecture with S#arpOnion Architecture with S#arp
Onion Architecture with S#arp
 
[2015/2016] Introduction to software architecture
[2015/2016] Introduction to software architecture[2015/2016] Introduction to software architecture
[2015/2016] Introduction to software architecture
 
The Magic Of Application Lifecycle Management In Vs Public
The Magic Of Application Lifecycle Management In Vs PublicThe Magic Of Application Lifecycle Management In Vs Public
The Magic Of Application Lifecycle Management In Vs Public
 
Clean architecture with asp.net core
Clean architecture with asp.net coreClean architecture with asp.net core
Clean architecture with asp.net core
 
Sw Software Design
Sw Software DesignSw Software Design
Sw Software Design
 
Modern Database Development Oow2008 Lucas Jellema
Modern Database Development Oow2008 Lucas JellemaModern Database Development Oow2008 Lucas Jellema
Modern Database Development Oow2008 Lucas Jellema
 
MDE in Practice
MDE in PracticeMDE in Practice
MDE in Practice
 
Action-Domain-Responder: A Web-Specific Refinement of Model-View-Controller
Action-Domain-Responder: A Web-Specific Refinement of Model-View-ControllerAction-Domain-Responder: A Web-Specific Refinement of Model-View-Controller
Action-Domain-Responder: A Web-Specific Refinement of Model-View-Controller
 
CQRS: A More Effective Way of Writing the Same Applications
CQRS: A More Effective Way of Writing the Same ApplicationsCQRS: A More Effective Way of Writing the Same Applications
CQRS: A More Effective Way of Writing the Same Applications
 
MVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVCMVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVC
 
DDS Advanced Tutorial - OMG June 2013 Berlin Meeting
DDS Advanced Tutorial - OMG June 2013 Berlin MeetingDDS Advanced Tutorial - OMG June 2013 Berlin Meeting
DDS Advanced Tutorial - OMG June 2013 Berlin Meeting
 
J2EE pattern 5
J2EE pattern 5J2EE pattern 5
J2EE pattern 5
 
Ria Mvc
Ria MvcRia Mvc
Ria Mvc
 
Vertical Slicing Architectures
Vertical Slicing ArchitecturesVertical Slicing Architectures
Vertical Slicing Architectures
 
DQ Product Usage Methodology Highlights_v6_ltd
DQ Product Usage Methodology Highlights_v6_ltdDQ Product Usage Methodology Highlights_v6_ltd
DQ Product Usage Methodology Highlights_v6_ltd
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Struts Ppt 1
Struts Ppt 1Struts Ppt 1
Struts Ppt 1
 
Multi-tenancy with Rails
Multi-tenancy with RailsMulti-tenancy with Rails
Multi-tenancy with Rails
 

Plus de Sandro Mancuso

Software Modernisation: a strategic approach
Software Modernisation: a strategic approachSoftware Modernisation: a strategic approach
Software Modernisation: a strategic approachSandro Mancuso
 
Aligning Product and Software Design
Aligning Product and Software DesignAligning Product and Software Design
Aligning Product and Software DesignSandro Mancuso
 
A Case for Outside-In Design
A Case for Outside-In DesignA Case for Outside-In Design
A Case for Outside-In DesignSandro Mancuso
 
Legacy Code Hands-on Session
Legacy Code Hands-on Session Legacy Code Hands-on Session
Legacy Code Hands-on Session Sandro Mancuso
 
Software Craftsmanship
Software CraftsmanshipSoftware Craftsmanship
Software CraftsmanshipSandro Mancuso
 
Software Craftsmanship - JAX London 2011
Software Craftsmanship - JAX London 2011Software Craftsmanship - JAX London 2011
Software Craftsmanship - JAX London 2011Sandro Mancuso
 

Plus de Sandro Mancuso (6)

Software Modernisation: a strategic approach
Software Modernisation: a strategic approachSoftware Modernisation: a strategic approach
Software Modernisation: a strategic approach
 
Aligning Product and Software Design
Aligning Product and Software DesignAligning Product and Software Design
Aligning Product and Software Design
 
A Case for Outside-In Design
A Case for Outside-In DesignA Case for Outside-In Design
A Case for Outside-In Design
 
Legacy Code Hands-on Session
Legacy Code Hands-on Session Legacy Code Hands-on Session
Legacy Code Hands-on Session
 
Software Craftsmanship
Software CraftsmanshipSoftware Craftsmanship
Software Craftsmanship
 
Software Craftsmanship - JAX London 2011
Software Craftsmanship - JAX London 2011Software Craftsmanship - JAX London 2011
Software Craftsmanship - JAX London 2011
 

Dernier

The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfayushiqss
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburgmasabamasaba
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...masabamasaba
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 

Dernier (20)

The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 

Crafted Design - GeeCON 2014

  • 2.
  • 3.  What is this application about?  What are the main concepts?  What does this application do?  What are the main features?  Where do I need to change?  Where do I put a new feature?
  • 4.  Looking from above, I can’t see what the application does or is about  Architectural and design concepts mixed with domain  Badly structured packages/namespaces  I don’t know where to start  Classes and methods are too low level
  • 5. Example: Layered structure What does this application do? What is it about?
  • 6. Example: Layered-domain structure Books and Users. Cool, but what does this application do?
  • 7. Example: MVC structure Awesome. It’s a web application. So?
  • 8.
  • 9. MVC & MVC Variations • MVC (Smalltalk 76/80) • MVC (general concept – 1988) • Three-Tier Architecture (Presentation, Logic, Data) • MVC (Model 1/Model 2) • Model View Adapter (MVA) • Model View Presenter (MVP) • Model View ViewModel (MVVM) • Presentation-Abstraction-Control (PAC) • ….
  • 11. MVC & MVC Variations They are all wrong. But they are also right. It all depends on the ‘V’iew.
  • 12. Views impact MVC structure Depending on the view technology, Views and Controllers responsibility becomes more/less coupled or blurred.  Web applications  Single-page AJAX applications with stateless backend  Console-based applications  Desktop applications  Games  Mobile / tablets  External systems (talking via Queues / Webservices) However, the model should remain unchanged.
  • 13. MVC – A Macro Organisational Pattern Model V C M Delivery Mechanism
  • 14. “Model” is overloaded and confusing  Model (M in MVC)  Domain Model (DDD)  View Model  Data Model  Entities & Active Record  and other artificial definitions from MVC frameworks  Associated with the persistence mechanism?
  • 15. M => Domain Model (DDD) Domain Model combines state and behaviour, with more focus on the latter. DDD define a few building blocks to your domain:  Entities  Value Objects  Factories  Repositories  Services  Application  Domain  Infrastructure  Aggregates
  • 16. << Web app >> Embedded Domain Model Model V C DM Delivery Mechanism Infrastructure Infrastructure DB Queue
  • 17. Deployable Domain Model Delivery Mechanisms << external system >> << mobile app >> DB << deployable app >> Model Infrastructure DM <<W/S>> <<W/S>>
  • 18. Event-Driven Domain Model Delivery Mechanisms DB Queue << external app 2 >> << external app 1 >> << deployable app >> Model Infrastructure DMQueue <<event 1>> <<event 2>>
  • 19. Domain Model – Responsibilities UC = Use Case, DS = Domain Service, S = Infra. Service, R = Repository Model UC 1 R 3 DS 1 DS 3 R 1 S Infrastructure Impl DM DS 2 Impl UC 2 << web app >>
  • 20. Repositories (not DAOs) Model <<repository>> Library <<repository>> Users Infrastructure <<Mongo>> Books Domain Model <<Oracle>> Users “A Repository represents all objects of a certain type as a conceptual set. It acts like a collection, except with more elaborate querying capability.” ~ Eric Evans
  • 21. Command & Query Use Cases << web app >> Model R DS <<Write Model>> UC Model <<Read Model>> UC DB DB Queue <<domain events>>
  • 22. So, how does the app structure look like?
  • 23. Web project responsibility Control flow (invoke use cases) JSON / XML parsers or converters Page Objects, validators, etc Static files
  • 24. Core responsibility (simple project) Tells what the system is about Tells what the system does
  • 25. Core responsibility (bigger project) Epic / Theme Epic / Theme Epic / Theme Related domain concepts
  • 26. What is inside model packages? Aggregate root (entity) Repository Entity (part of Book aggregate) Domain Service Value Object (part of Book aggregate) Part of aggregate behaviour Repository Value Object (part of User aggregate) Aggregate root (entity) Domain Service
  • 27. What is inside infrastructure? Interfaces defined by the domain. Dependency Inversion Principle (DIP) CreditCardProcessor implementations Repository implementations
  • 28. Domain Model collaborations guideline C UC 1 UC 2 DS 1 DS 3 DS 2 R 3 R 1 cl cl cl cl C = Controller, UC = Use Case, DS = Domain Service, R = Repository, cl = class
  • 29. Class responsibility C UC DS R cl DB Input Output End of code branch Produces the output End of flow First to handle input Start of the flow Execution Flow  Closer to the input: Control flow, higher level abstraction, detailed work is delegated (e.g. ProcessTrade (UC), MakePayment (UC)) — More suitable for Outside-In TDD (mockist).  Closer to the output / end of branch: Specific and detailed behaviour, no delegation, lower level abstraction (e.g. Parse XML (Parser), Create User (Repository)) Domain Model entry point Domain Concept entry point
  • 30. Defining testing strategies and boundaries • Unit • Integration • Acceptance • Journey • Black box • Component • System • Functional • Alpha • Beta • Conformance • … Types of tests
  • 31. Testing strategies: User Journey Model UC 1 DM UC 2 << web app >> UC 1 UC 2 Tests the journey a user will have to do something useful in the system Application is tested as a black box normally using a BDD framework Use cases are facked. We just want to know if the application presents the user with the correct journey Designed according to User Stories and Features <<fake>> <<fake>>
  • 32. Infrastructure Impl Testing strategies: Acceptance (Action / Behavioural) UC DS 1 <<mock>> RDS 2 R Tests a behaviour (action) provided by the system Use Case is the entry point and all external dependencies are stubbed Domain Model Normally tested using a BDD framework
  • 33. Testing strategies: Integration Tests the classes at the system boundaries Infrastructure Impl UC DS 1 <<mock>> RDS 2 R Domain Model Normally done using an in- memory Database using a unit testing framework
  • 34. Testing strategies: Unit (Class level) Unit test at class/method level Infrastructure Impl UC DS 1 RRDS 2 Domain Model DS 1 DS 2 All collaborators are mocked / stubbed (spies)
  • 35. Testing strategies: End-to-End Model UC 1 R 3 DS 1 DS 3 R 1 S Infrastructure Impl DM DS 2 Impl UC 2 << web app >> Full application deployed Uses BDD framework, accessing a testing database and fake external dependencies Very few tests at this level, just to make sure application is wired properly
  • 36. Outside-In vs. Classic TDD  The closer to the input a class is, the more flow control and delegation it does.  The closer to the output a class is, the more specific and less delegation it does. Using Outside-in TDD starting from Controllers and/or Use Cases. Model UC 1 R 3 DS 1 DS 3 R 1 S Infrastructure Impl DM DS 2 Impl UC 2 << web app >>
  • 37. Answering the two original questions  What is the application about? (main concepts)  What does the application do? (main features) Expressed by nouns Expressed by verbs (Actions)
  • 38.