How to connect product management and software engineering.
In order to connect the time old divide between product management/sales with software development, Domain Driven Design contains a series of paradigm changes and techniques to deal with complexity which align the vision of the product and the learning that the development team get from it.
Contains code samples in Python to illustrate the concepts.
Presented at Python Floripa 2017 meetup.
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
Â
Domain Driven Design @ NewStore
1. NewStore Inc.
Domain Driven Design!
... or how to connect engineering
and product management.
Bernardo Torres
btorres@newstore.com
http://www.newstore.com/
2. NewStore Inc.
Topics
â Tension between Product and Engineering
â NewStoreâs Journey with DDD
â Strategic Patterns of DDD
â Forming contexts around subdomains
â Event Storming
â Tactical Patterns of DDD
â NewStore
Agenda
2
3. NewStore Inc.
Tension Between Product and Engineering
Product/Sales wants:
â A cool, good looking product
â A thousand features
â Sales wants fixed dates
â Issues: Epics and User Stories
â When? Yesterday
3
Engineering needs:
â A consistent, understandable,
pluggable architecture
â Low tech debt
â Issues: Tech Stories and Bugs
â When? When itâs ready
4. NewStore Inc.
Proxy between developers and the outside world
â Role is based on constant negotiation between engineering and Sales
â Replaces the Business Analyst from Waterfall paradigm
â Focused on features / product (platform) building
Dark Side
â Not always Domain Experts
â Can fall into pressure from Sales to break Scrum process
â Can isolate developers from the real world: lost in translation effect
What to do?
â Should be made aware of the role and implications of good/bad architecture
â Bugs and slow Time To Market
â Antipattern: refactoring sprint / bug killing sprint
Product Owner
4
5. NewStore Inc.
Founded by Stephan Schambach, ecommerce pioneer who started
Intershop & Demandware (now Salesforce Commerce Cloud)
â Ecommerce as a platform (specifically Mobile Retail)
â Provides the multi-tenant platform + APIs that plug into your ecommerce workflow
â Integrates with 3rd party providers (shipment, payment, taxes)
â From product browsing all the way to delivery (and everything in between)
â Provides a Retail App that is used by associates
â Provides a SDK that can be used to build a Consumer App
â Some companies build âon their ownâ (adidas)
â Some companies have it built by NewStore
â adidas GLITCH
NewStore - what we do
5
6. NewStore Inc.
Microservices at NewStore
6
Payment
Microservice
Shipment
Microservice
Backend-For-
Frontend
MicroserviceHTTP BFF MS
BFF MS
Rabbit
MQ
Events & RPC
Consumer App
HQ App
HTTP
Retail App
HTTP
7. NewStore Inc.
Main books:
â Domain Driven Design - Eric Evans
â Implementing Domain Driven Design - Vaughn Vernon
Principles that drive modeling as a iterative learning process
â Implementation is an expression of knowledge of the domain
â Connecting model and implementation
â Ubiquitous Language
â Context Mapping
â Interaction between Developers and Business Experts
Domain Driven Design
7
8. NewStore Inc.
Books were already known by a fraction
of the team
Readerâs club formed to study it
Always felt that we needed to be more aware of:
â Context mapping - interconnection between
teams and contexts
â Misalignments between teams/contexts and
their consequences
â Make product management aware of
sub-domains/contexts
â Finding business experts
NewStoreâs Journey with DDD
8
9. NewStore Inc.
Workshop with
Vaughn Vernon
â Helped spread the
knowledge around
the teams
â Created a bigger
consensus on ideas
which were
perceived by few
NewStoreâs Journey with DDD
9
10. NewStore Inc.
â Help you make sure youâre using the right models, language and ideas
â Best interaction is getting them with you on a whiteboard
â Hard to find? Who are they? What do they eat? Where do they live?
â Examples
â Seasoned professionals in the area - experience, but risk of old ideas
â Integrators - in the front lines of plugging the software with the clientâs platform
â Sales. Yes, Sales. Theyâre on the trenches and know how clients behave.
â Support. They know how clients struggle with the product.
â Interview with clientâs employees - video, text, direct.
â Books
Domain Experts
10
11. NewStore Inc.
â Areas of business your
company is into. Can be:
â Core: where the
competitive advantage is;
â Supporting: a needed
function, but not
strategic;
â Generic: no difference
from other systems in the
market.
Domain / Subdomains - Problem Space
11
12. NewStore Inc.
â How your company divides to
conquer the business theyâre into.
Can be:
â Core: main focus of investment;
â Supporting: choose between invest
the minimum, hire an outsourcing or
use generic solution;
â Generic: able to use generic solution
available in the market.
Antipatterns:
Outsourcing core contexts
Contexts - Solution Space
12
13. NewStore Inc.
â Language should be as close to the business as possible
â Search for the nouns, but also the verbs, the expressions, the models
â Divided per context. Example: SalesOrder vs. FulfillmentOrder
â Built with Domain Experts: in theory you should be able to show them the code
â Code implication:
â Have business logic separated from infrastructure and presentation layers
Example
Service naming: OrderNotification vs. Email.
Entity naming: Tenant vs. Customer, Consumer vs. Customer.
Antipatterns
â Technical / Abstract Language: ProxyAbstractInterfaceAdapter
â Naming models after their implementation
Ubiquitous Language
13
14. NewStore Inc.
Teams and contexts should align
â Knowledge areas are formed - specialists for each area
â Challenges:
â Reorganizing contexts involves changing people - even hiring when needed
â Contexts evolve with time - cuts are not static
â Load of work is very variable between teams
Possible Cuts
â By Use Case
â Around Features
â By Area of Expertise
â Chaotic
Antipatterns
â Viewing teams as work queues
Context Forming
14
15. NewStore Inc.
Forms contexts around the steps of an order
â As an initial cut made a lot of sense
â With time (and new features), the loose distribution of areas (e.g. payment, shipment) we
needed tremendous amount of coordination to deliver improvements.
â More general architecture around specialized areas was not possible (payment, shipment)
Example
Context Forming - by use case
15
# Buy
Checkout
Tax collector
Sales Order
Payment
Authorization
Shipping Options
# Explore
Product
Catalog
Pricebooks
Import
# Fulfillment
Associate
Shipment
# Routing
Logistics
Stock
# Financials
Reporting
Payment
Capture
16. NewStore Inc.
Let entities emerge naturally from the captured domain
language
â Get together with business experts and developers to figure
out the language. Capture (in that order):
â things that happen in our domain - Events
â orders that triggers these events - Commands
â entities that change with these Commands and Events
- Aggregates
â areas of knowledge that naturally come together and
that naturally are apart - Contexts
â Storming: first iterations should avoid discussions
â Aligns people on language
Event Storming
16
17. NewStore Inc.
Event Storming - Events
Events
âConsumer Email address updatedâ
âThe payment was rejected for lack of
funds.â
17
18. NewStore Inc.
Event Storming - Commands
Events
âConsumer Email address updatedâ
âThe payment was rejected for lack of
funds.â
18
Commands
âUpdate Email addressâ
âSend order confirmation Emailâ
âCapture Paymentâ
19. NewStore Inc.
Event Storming - Aggregates
Events
âConsumer Email address updatedâ
âThe payment was rejected for lack of
funds.â
19
Commands
âUpdate Email addressâ
âSend order confirmation Emailâ
âCapture Paymentâ
Aggregates
âConsumerâ
âInventory Item Availabilityâ
20. NewStore Inc.
Event Storming - Contexts
EventsCommands
Aggregates
EventsCommands
Aggregates
EventsCommands
Aggregates
EventsCommands
Aggregates
Contexts
âConsumer Self Serviceâ
âConsumer Communicationâ
â Listen closely to Language
of Domain Experts to identify
Contexts
21. NewStore Inc.
Forms contexts around knowledge areas
â Developers become experts in specific subjects
â Features are implemented inside the context: coordination needed is minimized
Example
Context Forming - by areas of expertise
21
# Payment
Authorization
Capture
Refund
# Routing
Logistics
Stock
Store
queue
# Financials
Accounting
Reporting
# Delivery
Shipping options
Shipment
booking
# Catalog
Product
Catalog
Pricebooks
22. NewStore Inc.
Even with context/team alignment, some features are still cross cutting
â Use people with cross cutting knowledge and cross cutting relationships
Example: Gift wrapping
Context Feature vs. Cross Cutting Feature
22
# Payment
Authorization
Capture
Refund
# Routing
Logistics
Stock
Store
queue
# Accounting
Reporting
Taxation
# Delivery
Shipping options
Shipment
booking
# Catalog
Product
Catalog
Pricebooks
23. NewStore Inc.
Relationships
â Partnership
â Shared Kernel
â Not so valid for Microservices (unless youâre talking about shared models)
â Customer / Supplier
â Anti-Corruption Layer
â Open Host Service
â Published Language
â Conformist
Example
JSON Schema definitions negotiations between teams - RPC and Events
Antipattern
â Separate Ways
â Big Ball of Mud
Context Mapping
23
24. NewStore Inc.
Object that has identity and a lifetime
â Control the identity generation (vs. using an external)
â Unique enough (e.g. UUID4) - low risk of collision
â Intention revealing interfaces
Example
â Person
Antipatterns
â Anemic model
Entities
24
26. NewStore Inc.
Immutable. Attribute of an Entity.
â If has identity it is not controlled by this aggregate.
â Put data that only make sense as a whole together - ex.: Weight (amount, unit)
â Know which data you control in your service
â Youâll store differently (e.g. JSONB or normalized)
â Allows you to create nice helpers around them
Example
â Address (in Address Book vs. in an Order) & Product (in Catalog vs. in an Order)
â Price (amount, currency) & Weight (amount, unit)
Value Objects
26
29. NewStore Inc.
Transaction boundaries for entity updating
â How to draw boundaries - part of the data you own
â Everything else is just a value object
â Choose an entity root and let clients use only that
Antipatterns
â Data donkey: exposing data from a different model
â The web of relationships
â Huge aggregate:
Aggregates
29
30. NewStore Inc.
Creation of data needs specialized handling
Know which type of data youâre dealing with beforehand:
â Entities - have identity and a lifecycle
â Value Objects - immutable and only makes sense as whole, not in parts
Your methods should describe what you do without needing to reveal how:
â Intention revealing interfaces
Gang of Four patterns that have a DDD-twist:
â Aggregates - transaction boundaries of data manipulation
â Factories - create specialized builders of consistent objects for specific use cases
â Repositories - treat persisted object as in-memory collections
â Adapters - isolate input and output of data from your service
Lifecycle of a Domain Object
30
31. NewStore Inc.
Objects should be created in a consistent state
â Create specialized functions / class methods that instantiate models and handles
initialization from start to finish
â All invariants should be asserted
â Adapters can be coded as Factories, converting from different representational
formats (Product.create_from_event)
Antipatterns
â Create empty object and pass it around,
changing it bit by bit
Factories
31
32. NewStore Inc.
Data in, data out
â In: Translate data from external models to your
internal representation
â Out: Create a easily consumable model for clients
Be conservative in what you do, be liberal in what you accept
from others - Postelâs Law
Antipatterns
â One model fits all: serialization, database, internal
model
â Relational database impedance mismatch
â Expose your entire model
Adapters
32
34. NewStore Inc.
Handling persistence as a in-memory collection
â Creates a layer of protection between the API layer, the domain layer and the
persistence layer
â Makes the actual persistence layer interchangeable
â Convenience for access
Antipatterns
â Mix-up layers
Repositories
34
35. NewStore Inc.
Model things that happen in the system as Domain Events
â Listen for phrases like: âwhen X happens, I need information from Y to do Zâ
â Observe & React vs. Command & Control
â Name them with names in the past
â Use the ubiquitous language
â Enables publish / subscribe (in memory / database / queue / bus) [Observer Pattern]
Business rules Examples
â âWhen payment is authorized, I should route an order to be fulfilled by a storeâ
â Solution:
â Listen for Checkout.confirmed
â Listen for payment authorization
â Act when you have both data
Antipatterns
â RPC Machine Gun
Domain Events
35
37. NewStore Inc.
Making pluggable designs
â Easy targets: Integration with 3rd Party services
â Distill your usage of the API by what are your intentions with it
Examples
Shipment providers - stages of development:
â Part of the fulfillment service
â One service that only knows one provider
â Multiple services, each with its own implementation
â Shipment API: abstract, expose through HTTP and place it in the DMZ
Antipatterns
â Service that knows it all
â Too early abstraction
Supple Design
37
40. NewStore Inc.
Evans, Eric. Domain-Driven Design: Tackling Complexity in the Heart of Software, Addison-Wesley 2004.
Gamma, E., Helm, R., Johnson, R. & Vlissides, J. (1995). Design patterns: Elements of reusable object-oriented
software. Reading, MA: Addison Wesley.
Oberdi, Obi. Domain Driven Design Refcard, Dzone 2016.
Vernon, Vaughn. Implementing Domain-Driven Design, Addison-Wesley 2004.
References
40
41. NewStore Inc.
The usual, only better
â Customizable working equipment (monitor type, Linux or Mac)
â Catered breakfast and lunch during the week
â 7 types of mixed nuts and 6 types of cereal for all day fueling
â Espresso machines for delicious crema-full caffeine injections
â Endless soda and beer for sugar breaks and socializing
â Spacious Berlin office along the Spree bank
â Townhall for employee gatherings and pizza parties
â 4 tennis tables & ongoing competitive tournaments
NewStore - the perks
41
42. NewStore Inc.
The Perks without a good working environment means nothing
â Innovation
â Working with awesome people - huge potential for learning
â Meetups
â Training budget
â Shared success
â Onboarding process: takes care of your visa process
â Respect for the worker: self-organization
â Flat hierarchies - Open collaboration
â Unmeetings + Townhall
NewStore - the human factor
42