Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Sustainable SPA with DDD - The beginning of a wonderful friendship?

Sustainable SPA with DDD - The beginning of a wonderful friendship?

Manfred Steyer

February 06, 2020
Tweet

More Decks by Manfred Steyer

Other Decks in Programming

Transcript

  1. @ManfredSteyer Contents 1) DDD in a Nutshell 2) Monorepos 3)

    Monorepos & DDD 4) DDD & Micro Frontends
  2. @ManfredSteyer About me… • Manfred Steyer ANGULARarchitects.io • Angular Trainings

    and Consultancy • Google Developer Expert (GDE) • Trusted Collaborator in the Angular Team Page ▪ 8 Manfred Steyer Public: Frankfurt, Munich, Vienna In-House: everywhere http://softwarearchitekt.at/workshops
  3. @ManfredSteyer Catalog Ordering Shared Feature Feature Feature Feature Feature UI

    UI UI UI UI UI UI UI UI Domain Domain Domain Domain Domain Domain Util Util Util Util Util Util Enterprise Monorepo Patterns, Nrwl 2018: https://tinyurl.com/y2jjxld7 @ManfredSteyer Shared Kernel (if really needed) & other libs Smart Comp. Dumb Comp.
  4. @ManfredSteyer Catalog Ordering Shared Feature API Feature Feature Feature Feature

    UI UI UI UI UI UI UI UI UI Domain Domain Domain Domain Domain Domain Util Util Util Util Util Util @ManfredSteyer
  5. @ManfredSteyer Catalog Ordering Shared Feature API Feature Feature Feature Feature

    UI UI UI UI UI UI UI UI UI Domain Domain Domain Domain Domain Domain Util Util Util Util Util Util @ManfredSteyer
  6. @ManfredSteyer Application Domain Infrastructure Isolate your domain! Domain e. g.

    data access Use case specific facades, state management Entities, biz logic
  7. @ManfredSteyer Alternatives to layering • e. g. Hexagonal Architecture, Clean

    Architecture • Anyway: We need to restrict access b/w libraries
  8. @ManfredSteyer Finegrained Libraries • Unit of recompilation • Unit of

    retesting • Access restrictions • Information Hiding
  9. @ManfredSteyer Facade (Application Service) @Injectable({ providedIn: 'root' }) export class

    ProductFacade { public products: Product[] = []; […] } State!
  10. @ManfredSteyer Facade (Application Service) @Injectable({ providedIn: 'root' }) export class

    ProductFacade { public products: Product[] = []; constructor(private productService: ProductService) { } […] }
  11. @ManfredSteyer Facade (Application Service) @Injectable({ providedIn: 'root' }) export class

    ProductFacade { public products: Product[] = []; constructor(private productService: ProductService) { } search(category: string): void { […] } }
  12. @ManfredSteyer Facade (Application Service) @Injectable({ providedIn: 'root' }) export class

    ProductFacade { public products: Product[] = []; constructor(private productService: ProductService) { } search(category: string): void { […] } } SPA has to pull :-(
  13. @ManfredSteyer Facade (Application Service) @Injectable({ providedIn: 'root' }) export class

    ProductFacade { public products: Observable<Product[]>; constructor(private productService: ProductService) { } search(category: string): void { […] } } Also key for messaging
  14. @ManfredSteyer Entity/ Aggregate Root (OOP) public class BoardingList { private

    int id; private int flightId; private List<BoardingListEntry> entries; private boolean completed; // Getters and Setters public void setStatus(int passengerId, BoardingStatus status) { // Complex logic to update status } }
  15. @ManfredSteyer Entities (FP) export interface BoardingList { readonly id: number;

    readonly flightId: number; readonly entries: BoardingListEntry[]; readonly completed: boolean; } export function updateBoardingStatus( boardingList: BoardingList, passengerId: number, status: BoardingStatus) { // Complex logic to update status }
  16. @ManfredSteyer Catalog Ordering Shared Feature Feature Feature Feature Feature …

    … … … … … … … … @ManfredSteyer e-Procurement App Deployment Monolith
  17. @ManfredSteyer Catalog Ordering Shared Feature Feature Feature Feature Feature …

    … … … … … … … … @ManfredSteyer Catalog App Ordering App Option 1: One App per Domain
  18. @ManfredSteyer Catalog Ordering Shared Feature Feature Feature Feature Feature …

    … … … … … … … … @ManfredSteyer Catalog App Ordering App Option 2: One Monorepo per Domain Publish shared libs seperately via npm Different Versions
  19. Summary • Slicing into sub-domains • Slicing into layers •

    Finegrained libraries • Enforce restrictions • Fits to micro frontends
  20. @ManfredSteyer Contact and Downloads [web] ANGULARarchitects.io [twitter] ManfredSteyer d Slides

    & Examples Public: Frankfurt, Munich, Vienna In-House: everywhere http://softwarearchitekt.at/workshops