SlideShare una empresa de Scribd logo
1 de 46
Descargar para leer sin conexión
THE 80’S – RESPONSIBILITY DRIVEN DESIGN
THE 90’S – DESIGN PATTERNS
THE 2000’S – DOMAIN DRIVEN DESIGN
WHAT WILL BE COVERED
•  Business Domain Modeling
•  The Ubiquitous Language
•  Model Driven Design
•  Example Business Domain
•  Demonstrative Rails Application
WHAT WON’T BE COVERED
•  Refactoring Toward Deeper Insight
•  Supple Design
•  Large Scale Structure
•  Bounded Contexts
•  Distillation
MUSIC SCHOOL BUSINESS
•  Offers classes for playing music, singing, and dancing
•  Has a music instrument store that sells products
•  Hosts music events with famous musicians
•  Available in multiple locations
EXAMPLE WEBSITE
© Old Town School of Folk Music
BUSINESS DOMAIN MODELING
•  Knowledge Crunching
•  Continuous Learning
•  Deeper Models
KNOWLEDGE CRUNCHING
•  What types of classes do you offer?
•  Do you offer the same classes in all locations?
•  Do you sell anything other than music instruments?
•  Are events paid for or free?
•  How many classes does each instructor teach?
•  How many lessons is a class?
•  Do classes vary from session to session?
CONTINUOUS LEARNING AND DEEPER MODELS
•  Instructors perform regularly at events
•  Instructors provide series of classes
•  Certain events recur regularly
•  Music store offers location pick up service
THE UBIQUITOUS LANGUAGE
•  Model Out Loud
•  One Team, One Language
•  Documents and Diagrams
•  Executable Bedrock
•  Explanatory Models
MODEL OUT LOUD
•  Students register in a class with an instructor
•  Students attend events
•  Customers buy music products
•  Instructors teach classes
•  Locations offer classes
ONE TEAM, ONE LANGUAGE
•  Course vs Class
•  Student vs Customer
•  Teacher vs Instructor
•  Event vs Concert
•  Location vs Branch
DOCUMENTS
•  Top level goals
•  Top level requirements
•  Top level use cases
DIAGRAMS             Product

                                              Class Series
     Customer
                        Class



 Session
                                           Location
                    Event



       Instructor
                               Performer
EXECUTABLE BEDROCK AND
EXPLANATORY MODELS
•  Domain knowledge is apparent in code
•  Method names describe behavior
•  Class names map to actual business models
MODEL DRIVEN DESIGN
•  Object Oriented Paradigm and Mixing Paradigms
•  Layered Architecture
•  Associations
•  Entities
•  Value Objects
MODEL DRIVEN DESIGN
•  Services
•  Modules
•  Aggregates
•  Factories
•  Repositories
OBJECT ORIENTED PARADIGM
AND MIXING PARADIGMS
•  Objects can generally embody any domain
•  Certain domains can benefit from mixing paradigms:
•  Functional
•  Logic
•  Rule Engine
LAYERED ARCHITECTURE
ASSOCIATIONS
•  Unidirectional
•  Emphasizes natural bias for operation and domain logic
•  Communicates association better
•  Bidirectional
•  Multiple entry points for operation
ASSOCIATIONS
•  Buying
•  Enrollment
•  Performing
•  Location
•  Timing
ENTITIES
•  Have an identity independent of attributes
•  Mutable
•  Have a life cycle
•  In Rails, typically handled with ActiveRecord
•  When outgrowing ActiveRecord split into a separate
   Ruby stateful class
ENTITIES
•  Examples:
•  Customer
•  Instructor
•  Class
VALUE OBJECTS
•  Identified by their attribute values
•  Immutable and unique
•  In Rails, typically handled by pure Ruby objects
•  Examples:
•  City
•  State
•  Class Name
•  Session Date Range
AGGREGATES
•  Aggregate roots are entities aggregating other entities
•  Manage the life cycle events of other entities
•  Non-aggregates are discouraged from being accessed
   directly to simply reasoning about the domain code
•  In Rails, typically handled by ActiveRecord
•  When outgrowing ActiveRecord, split off into a stateful
   Ruby class and handle life-cycle hooks in an observer
AGGREGATES
•  Examples:
•  ClassSeries aggregates Classes
•  Customer aggregates Address
•  Location aggregates Address
FACTORIES
•  Handle creation of complex aggregate roots
•  In Rails, typically handled by ActiveRecord
•  When outgrowing ActiveRecord, split into a separete
   Ruby stateless class
FACTORIES
•  Examples:
•  ClassFactory handles creation of class with:
  •  Session association
  •  ClassCategory association
  •  Instructor association
REPOSITORIES
•  Handle storage and retrieval of aggregate roots
•  Manage lifecycle events
•  In Rails, typically handled by ActiveRecord
•  When outgrowing ActiveRecord, split into a separate
   stateless Ruby class that delegates work to ActiveRecord
REPOSITORIES
•  Examples:
 •  StudentRepository
 •  InstructorRepository
 •  SessionRepository
SERVICES
•  Model stateless business processes without a lifecycle
•  Useful for operations that span multiple entities
•  Often represent use cases
•  In Rails, typically represented in controllers that mix
   view concerns
•  When outgrowing Rails controllers, split into stateless
   Ruby service objects
SERVICES
•  Examples:
•  ClassEnrollmentService
•  MusicStoreService
•  EventTicketingService
MODULES
•  Package cohesive units of business behavior
•  Cut across software layers
•  In Rails, handled with Modules and Rails Engines
•  Examples:
•  MusicStore
•  ClassesEnrollment
•  EventTicketing
RUBY ON RAILS APPLICATION
RUBY ON RAILS APPLICATION
RUBY ON RAILS APPLICATION
RUBY ON RAILS APPLICATION
RUBY ON RAILS APPLICATION
RUBY ON RAILS APPLICATION
WHAT WAS COVERED
•  Business Domain Modeling
•  The Ubiquitous Language
•  Model Driven Design
•  Example Business Domain
•  Demonstrative Rails Application
QUESTIONS
   ???
2010’S - ???
REFERENCES
•  Domain-Driven Design by Eric Evans
CONTACT INFO
•  Andy Maleh / Software Engineer / Groupon
•  Blog: http://andymaleh.blogspot.com
•  Twitter: @AndyMaleh

Más contenido relacionado

La actualidad más candente

Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®
Hannes Lowette
 
Bridging the Gap - Laracon 2013
Bridging the Gap - Laracon 2013Bridging the Gap - Laracon 2013
Bridging the Gap - Laracon 2013
Ben Corlett
 

La actualidad más candente (19)

Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
Whitepages Practical Experience Converting from Ruby to Reactive
Whitepages Practical Experience Converting from Ruby to ReactiveWhitepages Practical Experience Converting from Ruby to Reactive
Whitepages Practical Experience Converting from Ruby to Reactive
 
Scala Jump Start
Scala Jump StartScala Jump Start
Scala Jump Start
 
Scala Native: Ahead of Time
Scala Native: Ahead of TimeScala Native: Ahead of Time
Scala Native: Ahead of Time
 
UPenn on Rails intro
UPenn on Rails introUPenn on Rails intro
UPenn on Rails intro
 
Akkurate Akka
Akkurate AkkaAkkurate Akka
Akkurate Akka
 
Agile North East Agile + DevOps by Craig Pearson of CAP Project Services
Agile North East Agile + DevOps by Craig Pearson of CAP Project ServicesAgile North East Agile + DevOps by Craig Pearson of CAP Project Services
Agile North East Agile + DevOps by Craig Pearson of CAP Project Services
 
A Swift introduction a.k.a Fun with Minions!
A Swift introduction a.k.a Fun with Minions!A Swift introduction a.k.a Fun with Minions!
A Swift introduction a.k.a Fun with Minions!
 
Staging and Deployment
Staging and DeploymentStaging and Deployment
Staging and Deployment
 
Serverless: when functions and GitOps collide
Serverless: when functions and GitOps collideServerless: when functions and GitOps collide
Serverless: when functions and GitOps collide
 
Scala Introduction - Meetup Scaladores RJ
Scala Introduction - Meetup Scaladores RJScala Introduction - Meetup Scaladores RJ
Scala Introduction - Meetup Scaladores RJ
 
Webservices: The RESTful Approach
Webservices: The RESTful ApproachWebservices: The RESTful Approach
Webservices: The RESTful Approach
 
Lessons Learned: Scala and its Ecosystem
Lessons Learned: Scala and its EcosystemLessons Learned: Scala and its Ecosystem
Lessons Learned: Scala and its Ecosystem
 
The Apache Way
The Apache WayThe Apache Way
The Apache Way
 
20171108 PDN HOL React Basics
20171108 PDN HOL React Basics20171108 PDN HOL React Basics
20171108 PDN HOL React Basics
 
Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®
 
Application Deployment at UC Riverside
Application Deployment at UC RiversideApplication Deployment at UC Riverside
Application Deployment at UC Riverside
 
Bridging the Gap - Laracon 2013
Bridging the Gap - Laracon 2013Bridging the Gap - Laracon 2013
Bridging the Gap - Laracon 2013
 
GitHub as a Landing Page
GitHub as a Landing Page GitHub as a Landing Page
GitHub as a Landing Page
 

Similar a Software Design Trilogy Part III - Domain Driven Design for Ruby on Rails Applications

Design Pattern Zoology
Design Pattern ZoologyDesign Pattern Zoology
Design Pattern Zoology
Josh Adell
 
Cloud development professional_training_module_1603813251908
Cloud development professional_training_module_1603813251908Cloud development professional_training_module_1603813251908
Cloud development professional_training_module_1603813251908
prasennabhai
 
Object Oriented Analysis & Design
Object Oriented Analysis & DesignObject Oriented Analysis & Design
Object Oriented Analysis & Design
vishykn
 

Similar a Software Design Trilogy Part III - Domain Driven Design for Ruby on Rails Applications (20)

Digitization revealed (2018 NLA Annual Conference)
Digitization revealed (2018 NLA Annual Conference)Digitization revealed (2018 NLA Annual Conference)
Digitization revealed (2018 NLA Annual Conference)
 
Design Pattern Zoology
Design Pattern ZoologyDesign Pattern Zoology
Design Pattern Zoology
 
Domain Driven Design Ruby Ways - JURNAL 05/10/2017
Domain Driven Design Ruby Ways -  JURNAL 05/10/2017Domain Driven Design Ruby Ways -  JURNAL 05/10/2017
Domain Driven Design Ruby Ways - JURNAL 05/10/2017
 
[DevDay 2016] Design Pattern at a glance - Speaker: Tuan Do – Scrum Master a...
 [DevDay 2016] Design Pattern at a glance - Speaker: Tuan Do – Scrum Master a... [DevDay 2016] Design Pattern at a glance - Speaker: Tuan Do – Scrum Master a...
[DevDay 2016] Design Pattern at a glance - Speaker: Tuan Do – Scrum Master a...
 
Implementing DDD Concepts in PHP
Implementing DDD Concepts in PHPImplementing DDD Concepts in PHP
Implementing DDD Concepts in PHP
 
MongoDB at Agilysys: A Case Study
MongoDB at Agilysys: A Case StudyMongoDB at Agilysys: A Case Study
MongoDB at Agilysys: A Case Study
 
Testing-Tools-Magnitia-Content.pdf
Testing-Tools-Magnitia-Content.pdfTesting-Tools-Magnitia-Content.pdf
Testing-Tools-Magnitia-Content.pdf
 
Drupal vs WordPress
Drupal vs WordPressDrupal vs WordPress
Drupal vs WordPress
 
Introduction to Test Driven Development
Introduction to Test Driven DevelopmentIntroduction to Test Driven Development
Introduction to Test Driven Development
 
Alex Theedom Java ee revisits design patterns
Alex Theedom	Java ee revisits design patternsAlex Theedom	Java ee revisits design patterns
Alex Theedom Java ee revisits design patterns
 
SE2016 Java Alex Theedom "Java EE revisits design patterns"
SE2016 Java Alex Theedom "Java EE revisits design patterns"SE2016 Java Alex Theedom "Java EE revisits design patterns"
SE2016 Java Alex Theedom "Java EE revisits design patterns"
 
Schibsted Spain - Day 1 - DDD Course
Schibsted Spain - Day 1 - DDD CourseSchibsted Spain - Day 1 - DDD Course
Schibsted Spain - Day 1 - DDD Course
 
Introduction to Testing and TDD
Introduction to Testing and TDDIntroduction to Testing and TDD
Introduction to Testing and TDD
 
Leveraging D2L’s LOR for Consistency, Scalability and Student Success in Cour...
Leveraging D2L’s LOR for Consistency, Scalability and Student Success in Cour...Leveraging D2L’s LOR for Consistency, Scalability and Student Success in Cour...
Leveraging D2L’s LOR for Consistency, Scalability and Student Success in Cour...
 
Domain Driven Design Demonstrated
Domain Driven Design Demonstrated Domain Driven Design Demonstrated
Domain Driven Design Demonstrated
 
Automating Complex High-Volume Technical Paper and Journal Article Page Compo...
Automating Complex High-Volume Technical Paper and Journal Article Page Compo...Automating Complex High-Volume Technical Paper and Journal Article Page Compo...
Automating Complex High-Volume Technical Paper and Journal Article Page Compo...
 
Cloud development professional_training_module_1603813251908
Cloud development professional_training_module_1603813251908Cloud development professional_training_module_1603813251908
Cloud development professional_training_module_1603813251908
 
Sap abap course
Sap abap course Sap abap course
Sap abap course
 
Sap abap course content
Sap abap course contentSap abap course content
Sap abap course content
 
Object Oriented Analysis & Design
Object Oriented Analysis & DesignObject Oriented Analysis & Design
Object Oriented Analysis & Design
 

Más de Andy Maleh

Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
Andy Maleh
 
Software Craftsmanship VS Software Engineering
Software Craftsmanship VS Software EngineeringSoftware Craftsmanship VS Software Engineering
Software Craftsmanship VS Software Engineering
Andy Maleh
 
Software Design Trilogy Part I - Responsibility Driven Design for Rubyists
Software Design Trilogy Part I - Responsibility Driven Design for RubyistsSoftware Design Trilogy Part I - Responsibility Driven Design for Rubyists
Software Design Trilogy Part I - Responsibility Driven Design for Rubyists
Andy Maleh
 
The Rails Engine That Could - In Motion
The Rails Engine That Could - In MotionThe Rails Engine That Could - In Motion
The Rails Engine That Could - In Motion
Andy Maleh
 

Más de Andy Maleh (17)

Fukuoka Ruby Award 2023 - Opal
Fukuoka Ruby Award 2023 - OpalFukuoka Ruby Award 2023 - Opal
Fukuoka Ruby Award 2023 - Opal
 
Becoming a SOC2 Ruby Shop - Montreal.rb November, 5, 2022 Ruby Meetup
Becoming a SOC2 Ruby Shop - Montreal.rb November, 5, 2022 Ruby MeetupBecoming a SOC2 Ruby Shop - Montreal.rb November, 5, 2022 Ruby Meetup
Becoming a SOC2 Ruby Shop - Montreal.rb November, 5, 2022 Ruby Meetup
 
Montreal.rb 2022-10-05 - Glimmer DSL for SWT - Ruby Desktop Development GUI ...
 Montreal.rb 2022-10-05 - Glimmer DSL for SWT - Ruby Desktop Development GUI ... Montreal.rb 2022-10-05 - Glimmer DSL for SWT - Ruby Desktop Development GUI ...
Montreal.rb 2022-10-05 - Glimmer DSL for SWT - Ruby Desktop Development GUI ...
 
How I Built My Code Editor in Ruby
How I Built My Code Editor in RubyHow I Built My Code Editor in Ruby
How I Built My Code Editor in Ruby
 
Ultra Light and Maintainable Rails Wizards at RailsConf 2014
Ultra Light and Maintainable Rails Wizards at RailsConf 2014Ultra Light and Maintainable Rails Wizards at RailsConf 2014
Ultra Light and Maintainable Rails Wizards at RailsConf 2014
 
RailsConf 2014 Recap at Montreal.rb by Andy Maleh
RailsConf 2014 Recap at Montreal.rb by Andy MalehRailsConf 2014 Recap at Montreal.rb by Andy Maleh
RailsConf 2014 Recap at Montreal.rb by Andy Maleh
 
Ultra Light and Maintainable Wizards in Rails at Montreal.rb
Ultra Light and Maintainable Wizards in Rails at Montreal.rbUltra Light and Maintainable Wizards in Rails at Montreal.rb
Ultra Light and Maintainable Wizards in Rails at Montreal.rb
 
Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
 
Software Craftsmanship VS Software Engineering
Software Craftsmanship VS Software EngineeringSoftware Craftsmanship VS Software Engineering
Software Craftsmanship VS Software Engineering
 
Rails Engine Patterns
Rails Engine PatternsRails Engine Patterns
Rails Engine Patterns
 
Software Craftsmanship vs Software Engineering (Lightning Talk)
Software Craftsmanship vs Software Engineering (Lightning Talk)Software Craftsmanship vs Software Engineering (Lightning Talk)
Software Craftsmanship vs Software Engineering (Lightning Talk)
 
Software Design Trilogy Part II - Design Patterns for Rubyists
Software Design Trilogy Part II - Design Patterns for RubyistsSoftware Design Trilogy Part II - Design Patterns for Rubyists
Software Design Trilogy Part II - Design Patterns for Rubyists
 
Software Design Trilogy Part I - Responsibility Driven Design for Rubyists
Software Design Trilogy Part I - Responsibility Driven Design for RubyistsSoftware Design Trilogy Part I - Responsibility Driven Design for Rubyists
Software Design Trilogy Part I - Responsibility Driven Design for Rubyists
 
The Rails Engine That Could - In Motion
The Rails Engine That Could - In MotionThe Rails Engine That Could - In Motion
The Rails Engine That Could - In Motion
 
The Rails Engine That Could
The Rails Engine That CouldThe Rails Engine That Could
The Rails Engine That Could
 
How I Learned To Apply Design Patterns
How I Learned To Apply Design PatternsHow I Learned To Apply Design Patterns
How I Learned To Apply Design Patterns
 
Simplifying Desktop Development With Glimmer
Simplifying Desktop Development With GlimmerSimplifying Desktop Development With Glimmer
Simplifying Desktop Development With Glimmer
 

Último

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Último (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

Software Design Trilogy Part III - Domain Driven Design for Ruby on Rails Applications

  • 1.
  • 2. THE 80’S – RESPONSIBILITY DRIVEN DESIGN
  • 3. THE 90’S – DESIGN PATTERNS
  • 4. THE 2000’S – DOMAIN DRIVEN DESIGN
  • 5. WHAT WILL BE COVERED •  Business Domain Modeling •  The Ubiquitous Language •  Model Driven Design •  Example Business Domain •  Demonstrative Rails Application
  • 6. WHAT WON’T BE COVERED •  Refactoring Toward Deeper Insight •  Supple Design •  Large Scale Structure •  Bounded Contexts •  Distillation
  • 7. MUSIC SCHOOL BUSINESS •  Offers classes for playing music, singing, and dancing •  Has a music instrument store that sells products •  Hosts music events with famous musicians •  Available in multiple locations
  • 8. EXAMPLE WEBSITE © Old Town School of Folk Music
  • 9. BUSINESS DOMAIN MODELING •  Knowledge Crunching •  Continuous Learning •  Deeper Models
  • 10. KNOWLEDGE CRUNCHING •  What types of classes do you offer? •  Do you offer the same classes in all locations? •  Do you sell anything other than music instruments? •  Are events paid for or free? •  How many classes does each instructor teach? •  How many lessons is a class? •  Do classes vary from session to session?
  • 11. CONTINUOUS LEARNING AND DEEPER MODELS •  Instructors perform regularly at events •  Instructors provide series of classes •  Certain events recur regularly •  Music store offers location pick up service
  • 12. THE UBIQUITOUS LANGUAGE •  Model Out Loud •  One Team, One Language •  Documents and Diagrams •  Executable Bedrock •  Explanatory Models
  • 13. MODEL OUT LOUD •  Students register in a class with an instructor •  Students attend events •  Customers buy music products •  Instructors teach classes •  Locations offer classes
  • 14. ONE TEAM, ONE LANGUAGE •  Course vs Class •  Student vs Customer •  Teacher vs Instructor •  Event vs Concert •  Location vs Branch
  • 15. DOCUMENTS •  Top level goals •  Top level requirements •  Top level use cases
  • 16. DIAGRAMS Product Class Series Customer Class Session Location Event Instructor Performer
  • 17. EXECUTABLE BEDROCK AND EXPLANATORY MODELS •  Domain knowledge is apparent in code •  Method names describe behavior •  Class names map to actual business models
  • 18. MODEL DRIVEN DESIGN •  Object Oriented Paradigm and Mixing Paradigms •  Layered Architecture •  Associations •  Entities •  Value Objects
  • 19. MODEL DRIVEN DESIGN •  Services •  Modules •  Aggregates •  Factories •  Repositories
  • 20. OBJECT ORIENTED PARADIGM AND MIXING PARADIGMS •  Objects can generally embody any domain •  Certain domains can benefit from mixing paradigms: •  Functional •  Logic •  Rule Engine
  • 22. ASSOCIATIONS •  Unidirectional •  Emphasizes natural bias for operation and domain logic •  Communicates association better •  Bidirectional •  Multiple entry points for operation
  • 23. ASSOCIATIONS •  Buying •  Enrollment •  Performing •  Location •  Timing
  • 24. ENTITIES •  Have an identity independent of attributes •  Mutable •  Have a life cycle •  In Rails, typically handled with ActiveRecord •  When outgrowing ActiveRecord split into a separate Ruby stateful class
  • 26. VALUE OBJECTS •  Identified by their attribute values •  Immutable and unique •  In Rails, typically handled by pure Ruby objects •  Examples: •  City •  State •  Class Name •  Session Date Range
  • 27. AGGREGATES •  Aggregate roots are entities aggregating other entities •  Manage the life cycle events of other entities •  Non-aggregates are discouraged from being accessed directly to simply reasoning about the domain code •  In Rails, typically handled by ActiveRecord •  When outgrowing ActiveRecord, split off into a stateful Ruby class and handle life-cycle hooks in an observer
  • 28. AGGREGATES •  Examples: •  ClassSeries aggregates Classes •  Customer aggregates Address •  Location aggregates Address
  • 29. FACTORIES •  Handle creation of complex aggregate roots •  In Rails, typically handled by ActiveRecord •  When outgrowing ActiveRecord, split into a separete Ruby stateless class
  • 30. FACTORIES •  Examples: •  ClassFactory handles creation of class with: •  Session association •  ClassCategory association •  Instructor association
  • 31. REPOSITORIES •  Handle storage and retrieval of aggregate roots •  Manage lifecycle events •  In Rails, typically handled by ActiveRecord •  When outgrowing ActiveRecord, split into a separate stateless Ruby class that delegates work to ActiveRecord
  • 32. REPOSITORIES •  Examples: •  StudentRepository •  InstructorRepository •  SessionRepository
  • 33. SERVICES •  Model stateless business processes without a lifecycle •  Useful for operations that span multiple entities •  Often represent use cases •  In Rails, typically represented in controllers that mix view concerns •  When outgrowing Rails controllers, split into stateless Ruby service objects
  • 34. SERVICES •  Examples: •  ClassEnrollmentService •  MusicStoreService •  EventTicketingService
  • 35. MODULES •  Package cohesive units of business behavior •  Cut across software layers •  In Rails, handled with Modules and Rails Engines •  Examples: •  MusicStore •  ClassesEnrollment •  EventTicketing
  • 36. RUBY ON RAILS APPLICATION
  • 37. RUBY ON RAILS APPLICATION
  • 38. RUBY ON RAILS APPLICATION
  • 39. RUBY ON RAILS APPLICATION
  • 40. RUBY ON RAILS APPLICATION
  • 41. RUBY ON RAILS APPLICATION
  • 42. WHAT WAS COVERED •  Business Domain Modeling •  The Ubiquitous Language •  Model Driven Design •  Example Business Domain •  Demonstrative Rails Application
  • 43. QUESTIONS ???
  • 46. CONTACT INFO •  Andy Maleh / Software Engineer / Groupon •  Blog: http://andymaleh.blogspot.com •  Twitter: @AndyMaleh