domain driven design through onion architecture

Post on 28-Jun-2015

1.706 Views

Category:

Software

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

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.

TRANSCRIPT

Domain Driven DesignThrough Onion Architecture

Bowling Score Sheet

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.

Bowling Domain

•Who are the Domain Experts?

•What is the Ubiquitous Language?

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.

Bowling Bounded Contexts

•Scoring•Statistics•Lane Reservation•Sales•Maintenance

Traditional Layered Architecture

Presentation

Business/Domain

Data Access

Onion Architecture

Core

Domain

API

Infrastructure

The Core

• Building blocks used to create the application.

• Not specific to any domain or technology.

• Eg. Lists, Maps, Case Classes, Actors, Lenses

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

Bowling API

• Could include methods like:• Create Game• Add/Remove Player• Get Players• Set Pin State• Skip Player• Set Lane

The Domain

• Built out of the building blocks defined in the Core

• Uses Ubiquitous Language

• BUSINESS LOGIC GOES HERE!

Bowling Domain

• Domain Terms: Game, Player, Pin, Frame, Strike, Spare

• Out of Context: Pinsetter, Customer, Lane Reservation

• Non Domain Terms: User Interface, Database

Domain Building Blocks

• Value Objects• Entities• Aggregate Roots• Repositories• Factories• Services

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?

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)

Bowling Infrastructure

• Pinsetter• UI for lane screens• UI for alley staff• Database

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?

top related