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

How to accelerate DDD practice using Amazon Q D...

How to accelerate DDD practice using Amazon Q Developer

This is presentation deck for JAWS PANKRATION 2024

kanamsasa

August 24, 2024
Tweet

More Decks by kanamsasa

Other Decks in Technology

Transcript

  1. How to accelerate DDD practice using Amazon Q Developer Masao

    Kanamori(he/him) Amazon Web Services Japan G.K. Developer Specialist Solutions Architect
  2. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. About me Masao Kanamori Ø Title/Role : PACE(Prototyping and Cloud Engineering) Team Solutions Architect Ø Favorite avengers: Hawkeye: Clint Barton
  3. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Domain Driven Design
  4. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Domain Driven Design (DDD) Is a method to reduce complexity in large scale systems a) by reflecting the business domain in the system b) and decomposing it using Loose Coupling / High Cohesion principles Business Domain Model System reserve air ways itinerary user modeling reflect
  5. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Strategic Design / Tactical Design Strategic Design Tactical Design
  6. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Strategic Design Strategic Design Goal - Finding a domain model Practice - Ubiquitous Language - Bounded Context etc … Approach - Event Storming - Domain Storytelling etc …
  7. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Tactical Design Tactical Design Goal - Implementing a domain model Practice - Entities - Value Objects etc … Approach - Clean Architecture - Onion Architecture etc …
  8. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Difficulties in implementing DDD Especially for beginners , 1. There are too many practices!! 2. Where should we start coding? 3. How can we combine DDD and frameworks? Can someone help me? Amazon Q Developer I’m here!!
  9. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Q Developer Reimagines the experience across the entire software development lifecycle (SDLC) Helps developers and IT professionals build and manage secure, scalable, and highly available applications Helps you write, debug, test, optimize, and upgrade your code faster Converses with you to explore new AWS capabilities, learn unfamiliar technologies, and architect solutions Amazon Q is built with security and privacy in mind from the start, making it easier for organizations to use generative AI safely.
  10. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Result of Event Storming Auction created Start/end date set Item evaluated Customer tendered Customer won Create Auction Set start/end date Evaluate item Auction Tendered item Item Customer lose Determine Result Bought Item Inspected item Item stored Buy item Inspect item Store item Inventory Payment method chosen Purchase completed Payment Choose payment method Purchase Inventory context Auction context Payment context Customer joined Join auction Item listed List item
  11. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Discuss about aggregate Auction created Start/end date set Item evaluated Customer tendered Customer won Create Auction Set start/end date Evaluate item Auction Tendered item Item Customer lose Determine Result Customer joined Join auction List item Auction context Business rules / invariants •Item can be listed to Auction •When Item have already been listed on the other Auction, it should be error etc etc… Item listed
  12. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Ask Amazon Q to write model •Item can be listed to Auction •When Item have already been listed on the other Auction, it should be error Write class diagram for below scenario. Approach: DDD practice like Entity, Value Object , Repository, Domain Service and Application Service. Tool: PlantUML Scenario: •Item and Auction are aggregates <Prompt for Amazon Q> Amazon Q Developer <UMLs (using PlantUML)>
  13. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Generate blueprint code from model <UMLs (using plantUML)> Amazon Q Developer Write Java code with test according to this sequence diagram class Item { private ItemId itemId; private String title; … } class Auction { … } class ItemAppService { … } <Blueprint codes>
  14. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Points - You can use those diagrams and codes that are generated by Amazon Q as an example of how to implement tactical design of DDD. - Gen AI is not perfect and nondeterministic. - You need to / can adjust those diagrams and codes when you needed.
  15. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Next Step -> TDD • Test Driven Development repeats § ①Write a test that fails § ②Write minimal code necessary to pass the test § ③Refactor Amazon Q Developer Yes! I can support to write test, code to pass the test , and refactor.
  16. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Difficulties in implementing DDD Especially for beginners , 1. There are too many practices!! 2. Where should we start coding? 3. How can we combine DDD and frameworks?
  17. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Q can support that… ? OK, I’ll ask that Amazon Q! Where should I put domain models of selected sequence diagram in this project? Amazon Q Developer ❌
  18. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. By default… Amazon Q Developer doesn’t know what framework is used. Only the file that is currently open in your IDE is used as the context.
  19. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Introduce @workspace Beta Using @workspace in your prompt, Amazon Q Developer can use workspace as context. You can refer this blog to know more details like how it works. https://go.aws/46PrOhL
  20. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Using @workspace Where should I put domain models of selected sequence diagram in this @workspace Amazon Q Developer Beta
  21. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Summary • You can use Gen AI assistant as a teacher of DDD • Notice! Even teacher have mistakes • Letʼs go through trial and error!! Itʼs important for • finding good prompt • to become familiar with the DDD practice • The right tool for the job • For simple application, DDD may be too much • Amazon Q Developer inline code generation will help you