Domain Driven Design with Onion Architecture is a powerful combination of Architecture Patterns that can dramatically improve code quality and can help you learn a great deal about writing "clean" code.
3. What is Domain Driven Design
• A technique for developing software that
focuses on collaboration between technical
experts and domain experts.
• The ideas and terms of the domain should be
directly reflected by the code through the
Ubiquitous Language.
4. Bowling Domain
• Who are the Domain Experts?
• What is the Ubiquitous Language?
5. Bounded Contexts
• Subdivide large domains into smaller contexts.
• Each context can have it’s own ubiquitous
language and it’s own model.
• Bounded Contexts may share some domain
aspects.
9. The Core
• Building blocks used to create the
application.
• Not specific to any domain or technology.
• Eg. Lists, Maps, Case Classes, Actors, Lenses
10. The API
• Acts as an entry point to the Domain
• Communicates using Domain terms and
Domain objects
• Should be restricted to exposing only
immutable objects
• Can access the Core and the Domain but not
the Infrastructure
11. Bowling API
• Could include methods like:
• Create Game
• Add/Remove Player
• Get Players
• Set Pin State
• Skip Player
• Set Lane
12. The Domain
• Built out of the building blocks defined in the
Core
• Uses Ubiquitous Language
• BUSINESS LOGIC GOES HERE!
13. Bowling Domain
• Domain Terms: Game, Player, Pin, Frame,
Strike, Spare
• Out of Context: Pinsetter, Customer, Lane
Reservation
• Non Domain Terms: User Interface, Database
14. Domain Building Blocks
• Value Objects
• Entities
• Aggregate Roots
• Repositories
• Factories
• Services
15. Bowling Aggregate Root
• Candidates: Player, Game
• Which Entities are present in most or all API
operations?
• Which Entity if deleted would result in the
deletion of some or all other Entities?
16. The Infrastructure
• Contains adapters for various technology
concerns including Databases, User
Interfaces, External Services etc.
• Has access to all areas of the system (API,
Domain, Core)
18. Wrap Up
• How portable is the Bowling Score Keeper?
• Can it be adapted to other uses with minimal
effort?
• Is it tied to the underlying technology?