Slide 1

Slide 1 text

How to accelerate DDD practice using Amazon Q Developer Masao Kanamori(he/him) Amazon Web Services Japan G.K. Developer Specialist Solutions Architect

Slide 2

Slide 2 text

© 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

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

© 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

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

© 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 …

Slide 7

Slide 7 text

© 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 …

Slide 8

Slide 8 text

© 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!!

Slide 9

Slide 9 text

© 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.

Slide 10

Slide 10 text

© 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

Slide 11

Slide 11 text

© 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

Slide 12

Slide 12 text

© 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 Amazon Q Developer

Slide 13

Slide 13 text

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. Generate blueprint code from model 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 { … }

Slide 14

Slide 14 text

© 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.

Slide 15

Slide 15 text

© 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.

Slide 16

Slide 16 text

© 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?

Slide 17

Slide 17 text

© 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 ❌

Slide 18

Slide 18 text

© 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.

Slide 19

Slide 19 text

© 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

Slide 20

Slide 20 text

© 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

Slide 21

Slide 21 text

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. Summary

Slide 22

Slide 22 text

© 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