Share
Embed
The Fractal Geometry of Software Design
Presented at Domain-Driven Design Europe 2022 (Keynote)
Vlad Khononov
June 24, 2022
Annual Pro sale · Save $30
Have presentations of your own?
Share with private links, password protection, and more control over your work.
Transcript
144 slides
-
vladikk doit-intl.com #DDDEU • How much food do we need
to stay alive? • How creative are we? • How profitable are our companies? -
vladikk doit-intl.com #DDDEU West, G. (2018). Scale: The universal laws
of life and death in organisms, cities and companies. Weidenfeld & Nicolson. How much food do we need to stay alive? How creative are we? How profitable are our companies? -
vladikk doit-intl.com #DDDEU METABOLIC RATE OF ANIMALS West, G. (2018).
Scale: The universal laws of life and death in organisms, cities and companies. Weidenfeld & Nicolson. -
vladikk doit-intl.com #DDDEU REGISTERED PATENTS West, G. (2018). Scale: The
universal laws of life and death in organisms, cities and companies. Weidenfeld & Nicolson. -
vladikk doit-intl.com #DDDEU West, G. (2018). Scale: The universal laws
of life and death in organisms, cities and companies. Weidenfeld & Nicolson. INCOME AND ASSETS OF COMPANIES -
vladikk doit-intl.com #DDDEU West, G. (2018). Scale: The universal laws
of life and death in organisms, cities and companies. Weidenfeld & Nicolson. How much food do we need to stay alive? How creative are we? How profitable are our companies? -
vladikk doit-intl.com #DDDEU West, G. (2018). Scale: The universal laws
of life and death in organisms, cities and companies. Weidenfeld & Nicolson. How much food do we need to stay alive? How creative are we? How profitable are our companies? -
vladikk doit-intl.com #DDDEU West, G. (2018). Scale: The universal laws
of life and death in organisms, cities and companies. Weidenfeld & Nicolson. -
vladikk doit-intl.com #DDDEU METABOLIC RATE OF ANIMALS West, G. (2018).
Scale: The universal laws of life and death in organisms, cities and companies. Weidenfeld & Nicolson. -
vladikk doit-intl.com #DDDEU West, G. (2018). Scale: The universal laws
of life and death in organisms, cities and companies. Weidenfeld & Nicolson. How much food do we need to stay alive? How creative are we? How profitable are our companies? -
vladikk doit-intl.com #DDDEU "Viewed through this lens, cities, companies, plants,
animals, our bodies, and even tumors manifest a remarkable similarity in the ways that they are organized and function." - Geo ff rey West -
vladikk doit-intl.com #DDDEU AGENDA 1. A primer on energy supply
networks 2. How network theory applies to software design 3. Leveraging the network theory to manage complexity 4. S ^ D -
vladikk doit-intl.com #DDDEU ENERGY SUPPLY NETWORKS Systems that are sustained
by the transport of energy through hierarchical networks. -
vladikk doit-intl.com #DDDEU WHAT IS THE ENERGY SUPPLIED BY SOFTWARE
DESIGN? — KNOWLEDGE -
vladikk doit-intl.com #DDDEU KNOWLEDGE: THE ENERGY OF SOFTWARE DESIGN Implementation
Coupling Functional Coupling Model Coupling Contract Coupling -
vladikk doit-intl.com #DDDEU KNOWLEDGE: THE ENERGY OF SOFTWARE DESIGN Implementation
Coupling Functional Coupling Model Coupling Contract Coupling • How the parts of the system are implemented • Private interfaces • Not intended for inter-component integration -
vladikk doit-intl.com #DDDEU KNOWLEDGE: THE ENERGY OF SOFTWARE DESIGN Implementation
Coupling Functional Coupling Model Coupling Contract Coupling • Knowledge of what the system has to do • Business logic • Use cases • Rules, invariants, constraints -
vladikk doit-intl.com #DDDEU KNOWLEDGE: THE ENERGY OF SOFTWARE DESIGN Implementation
Coupling Functional Coupling Model Coupling Contract Coupling • Models of the business domain • Data structures • Software system-related aspects of the business domain • Understanding of the functional requirements -
vladikk doit-intl.com #DDDEU KNOWLEDGE: THE ENERGY OF SOFTWARE DESIGN Implementation
Coupling Functional Coupling Model Coupling Contract Coupling • Components’ integration contracts • Integration-specific models, APIs • The minimal data needed for components to work together -
vladikk doit-intl.com #DDDEU “System design is inherently about boundaries (what’s
in, what’s out, what spans, what moves between), and about tradeo ff s. It reshapes what is outside, just as it shapes what is inside.” - Ruth Malan (@ruthmalan) -
vladikk doit-intl.com #DDDEU KNOWLEDGE: THE ENERGY OF SOFTWARE DESIGN Knowledge
vs Data: TBs of data across a contract-based interface vs a few bytes across implementation-coupled modules -
vladikk doit-intl.com #DDDEU KNOWLEDGE: THE ENERGY OF SOFTWARE DESIGN So
ft ware systems are sustained by the transport of knowledge (energy) through hierarchical networks of modules. -
vladikk doit-intl.com #DDDEU West, G. (2018). Scale: The universal laws
of life and death in organisms, cities and companies. Weidenfeld & Nicolson. -
vladikk doit-intl.com #DDDEU West, G. (2018). Scale: The universal laws
of life and death in organisms, cities and companies. Weidenfeld & Nicolson. -
vladikk doit-intl.com #DDDEU METABOLIC RATE OF ANIMALS West, G. (2018).
Scale: The universal laws of life and death in organisms, cities and companies. Weidenfeld & Nicolson. -
vladikk doit-intl.com #DDDEU METABOLIC RATE OF ANIMALS West, G. (2018).
Scale: The universal laws of life and death in organisms, cities and companies. Weidenfeld & Nicolson. -
vladikk doit-intl.com #DDDEU y = 3.4 * x3/4 West, G.
(2018). Scale: The universal laws of life and death in organisms, cities and companies. Weidenfeld & Nicolson. -
vladikk doit-intl.com #DDDEU y = 3.4 * x3/4 y =
x Sublinear Growth Linear Growth Sublinear function grows slower than any linear function -
vladikk doit-intl.com #DDDEU Chihuahua Yorkshire Terrier Pug Beagle Boxer Newfoundland
1.8kg 3.5kg 7kg 14.5kg 29kg 58kg -
vladikk doit-intl.com #DDDEU Chihuahua Yorkshire Terrier Pug Beagle Boxer Newfoundland
1.8kg 3.5kg 7kg 14.5kg 29kg 58kg BASAL METABOLIC RATE The minimum number of calories a day needed to stay alive without performing any activities. https://www.sciencedirect.com/topics/engineering/basal-metabolic-rate -
vladikk doit-intl.com #DDDEU Chihuahua Yorkshire Terrier Pug Beagle Boxer Newfoundland
1.8kg 3.5kg 7kg 14.5kg 29kg 58kg 110 220 440 880 1,760 3,520 Breed Weight Basal Metabolic Rate -
vladikk doit-intl.com #DDDEU Chihuahua Yorkshire Terrier Pug Beagle Boxer Newfoundland
1.8kg 3.5kg 7kg 14.5kg 29kg 58kg 110 220 440 880 1,760 3,520 110 180 302 521 876 1,474 Breed Weight Linear Thinking Basal Metabolic Rate -
vladikk doit-intl.com #DDDEU West, G. (2018). Scale: The universal laws
of life and death in organisms, cities and companies. Weidenfeld & Nicolson. NO. OF GASOLINE STATIONS -
vladikk doit-intl.com #DDDEU West, G. (2018). Scale: The universal laws
of life and death in organisms, cities and companies. Weidenfeld & Nicolson. -
vladikk doit-intl.com #DDDEU REGISTERED PATENTS West, G. (2018). Scale: The
universal laws of life and death in organisms, cities and companies. Weidenfeld & Nicolson. -
vladikk doit-intl.com #DDDEU y = x1.15 y = x West,
G. (2018). Scale: The universal laws of life and death in organisms, cities and companies. Weidenfeld & Nicolson. -
vladikk doit-intl.com #DDDEU y = x1.15 y = x Superlinear
Growth Linear Growth Superlinear function grows faster than any linear function -
vladikk doit-intl.com #DDDEU ECONOMIES OF SCALE Superlinear Growth Sublinear
Growth Linear Growth -
vladikk doit-intl.com #DDDEU KNOWLEDGE: THE ENERGY OF SOFTWARE DESIGN So
ft ware systems are sustained by the transport of knowledge (energy) through hierarchical networks of modules. -
vladikk doit-intl.com #DDDEU ECONOMIES OF SCALE Superlinear Growth Sublinear
Growth Linear Growth -
vladikk doit-intl.com #DDDEU "You can plainly see the impossibility of
increasing the size of structures to vast dimensions either in art or in nature; … also it would be impossible to build up the bony structures of men, horses, or other animals so as to hold together and perform their normal functions . . . for if his height be increased inordinately he will fall and be crushed under his own weight.” - Galileo Galilei -
vladikk doit-intl.com #DDDEU Cross-section Resistance to fracture is proportional to
the cross-sectional area -
vladikk doit-intl.com #DDDEU x2 x2 x2 Weight increase: Strength increase:
2 * 2 * 2 = x8 2 * 2 = x4 -
vladikk doit-intl.com #DDDEU GROWTH LIMITS Superlinear Growth Sublinear
Growth Linear Growth • As a system grows, it becomes more efficient • Undesired consequences of growth become more efficient as well -
vladikk doit-intl.com #DDDEU ORGANISMS • Limbs are unable to support
the overall weight • The amount of cells surpasses capillaries’ ability to supply energy • All available energy used for repairing consequences of entropy CITIES • Overcrowding • Crime rates • Pollution • Spread of diseases COMPANIES • Sublinear scaling of sales, incomes, and profits • Bureaucracy • Administration and management complexity SOFTWARE SYSTEMS ? -
vladikk doit-intl.com #DDDEU Knowledge (sublinear growth) Complexity (superlinear growth) Cognitive
Limit (No growth) Functionality (Linear growth) -
vladikk doit-intl.com #DDDEU Knowledge Miller, G. A. (1994). The magical
number seven, plus or minus two: Some limits on our capacity for processing information. Psychological Review, 101(2), 343–352 ESTIMATED CAPACITY FOR PROCESSING INFORMATION 2000s: 4 +/- 1 Cowan, Nelson. "The magical number 4 in short-term memory: A reconsideration of mental storage capacity." Behavioral and brain sciences 24.1 (2001): 87-114. -
vladikk doit-intl.com #DDDEU Knowledge (sublinear growth) Complexity (superlinear growth) Cognitive
Limit (No growth) Functionality (Linear growth) -
vladikk doit-intl.com #DDDEU Knowledge (sublinear growth) Complexity (superlinear growth) Cognitive
Limit (No growth) Functionality (Linear growth) -
vladikk doit-intl.com #DDDEU “I have sketched a bone whose natural
length has been increased three times and whose thickness has been multiplied until, for a correspondingly large animal, it would perform the same function which the small bone performs for its small animal” - Galileo Galilei -
vladikk doit-intl.com #DDDEU “if one wishes to maintain in a
great giant the same proportion of limb as that found in an ordinary man he must find a harder and stronger material for making the bones” - Galileo Galilei -
vladikk doit-intl.com #DDDEU POSTPONING GROWTH LIMITS 1. Adapt form /
shape to withstand increased stress 2. Use stronger materials -
vladikk doit-intl.com #DDDEU ORGANISMS • Limbs are unable to support
the overall weight • Crime rates • Pollution • Spread of diseases COMPANIES • Sublinear scaling of sales, incomes, and profits -
vladikk doit-intl.com #DDDEU https://en.wikipedia.org/wiki/List_of_largest_cities_throughout_history Stone tools, Fire, Bow, Wheel Writing
Water Mill Gunpowder Printing Press Optical Lens Steam Engine Telegraph Plastics Airplane Transistor Nuclear Power Space Flight Internet Mobile Technology -
vladikk doit-intl.com #DDDEU "Technology can bring benefits if, and only
if, it diminishes a limitation’" - Eliyahu M. Goldratt -
vladikk doit-intl.com #DDDEU “if one wishes to maintain in a
great giant the same proportion of limb as that found in an ordinary man he must find a harder and stronger material for making the bones” - Galileo Galilei -
vladikk doit-intl.com #DDDEU Knowledge (sublinear growth) Complexity (superlinear growth) Cognitive
Limit (No growth) Functionality (Linear growth) Cognitive Limit (superlinear growth) -
vladikk doit-intl.com #DDDEU “I have sketched a bone whose natural
length has been increased three times and whose thickness has been multiplied until, for a correspondingly large animal, it would perform the same function which the small bone performs for its small animal” - Galileo Galilei -
vladikk doit-intl.com #DDDEU "Highly complex, self-sustaining structures, whether cells, organisms,
ecosystems, cities, or corporations, require the close integration of enormous numbers of their constituent units that need e ff icient servicing at all scales. This has been accomplished in living systems by evolving fractal-like, hierarchical branching network systems.” - Geo ff rey West -
vladikk doit-intl.com #DDDEU Y. Chen, P. Cheng, Heat transfer and
pressure drop in fractal tree-like microchannel nets Lorthois, Sylvie, and Francis Cassot. "Fractal analysis of vascular networks: insights from morphogenesis." Journal of theoretical biology 262.4 (2010): 614-633. -
vladikk doit-intl.com #DDDEU https://opte.org Klinkhamer, Christopher, et al. "Functionally fractal
urban networks: Geospatial co-location and homogeneity of infrastructure." -
vladikk doit-intl.com #DDDEU Chihuahua Yorkshire Terrier Pug Beagle Boxer Newfoundland
1.8kg 3.5kg 7kg 14.5kg 29kg 58kg 110 220 440 880 1,760 3,520 110 180 302 521 876 1,474 Breed Weight Linear Thinking Basal Metabolic Rate -
vladikk doit-intl.com #DDDEU West, G. (2018). Scale: The universal laws
of life and death in organisms, cities and companies. Weidenfeld & Nicolson. NO. OF GASOLINE STATIONS -
vladikk doit-intl.com #DDDEU Sublinear Growth Linear Growth Sublinear
function grows slower than any linear function -
vladikk doit-intl.com #DDDEU Knowledge (sublinear growth) Complexity (superlinear growth) Cognitive
Limit (No growth) Functionality (Linear growth) Complexity Sublinear growth) -
vladikk doit-intl.com #DDDEU KNOWLEDGE: THE ENERGY OF SOFTWARE DESIGN Implementation
Coupling Functional Coupling Model Coupling Contract Coupling Shared Knowledge Encapsulated Knowledge Boundaries Encapsulated Knowledge -
vladikk doit-intl.com #DDDEU KNOWLEDGE: THE ENERGY OF SOFTWARE DESIGN So
ft ware systems are sustained by the transport of knowledge (energy) through hierarchical networks of modules. -
vladikk doit-intl.com #DDDEU Y. Chen, P. Cheng, Heat transfer and
pressure drop in fractal tree-like microchannel nets -
vladikk doit-intl.com #DDDEU Knowledge (sublinear growth) Complexity (superlinear growth) Cognitive
Limit (No growth) Functionality (Linear growth) -
vladikk doit-intl.com #DDDEU INTEGRATION STRENGTH (S) Implementation Coupling Functional Coupling
Model Coupling Contract Coupling Shared Knowledge Encapsulated Knowledge Boundaries Encapsulated Knowledge -
vladikk doit-intl.com #DDDEU DISTANCE (D) M ethods Classes Sub-M odules
M odules Com ponents (M icro)Services System s Coordination -
vladikk doit-intl.com #DDDEU COST OF CHANGE IS PROPORTIONAL TO THE
DISTANCE BETWEEN COMPONENTS -
vladikk doit-intl.com #DDDEU Downstream Module Upstream Module depends on Integration
Strength (S) Distance (D) -
vladikk doit-intl.com #DDDEU LOW STRENGTH HIGH STRENGTH ? LOW DISTANCE
HIGH DISTANCE • High cost of cascading changes • Low shared knowledge • Minimizes cascading changes -
vladikk doit-intl.com #DDDEU LOW STRENGTH HIGH STRENGTH Loose Coupling LOW
DISTANCE HIGH DISTANCE • High cost of cascading changes • Low shared knowledge • Minimizes cascading changes -
vladikk doit-intl.com #DDDEU LOW STRENGTH HIGH STRENGTH ? Loose Coupling
LOW DISTANCE HIGH DISTANCE • High shared knowledge • Frequent cascading changes • Low cost of cascading changes -
vladikk doit-intl.com #DDDEU LOW STRENGTH HIGH STRENGTH High Cohesion
Loose Coupling LOW DISTANCE HIGH DISTANCE • High shared knowledge • Frequent cascading changes • Low cost of cascading changes -
vladikk doit-intl.com #DDDEU High Cohesion LOW STRENGTH HIGH STRENGTH
? Loose Coupling LOW DISTANCE HIGH DISTANCE • Low cost of cascading changes • Low shared knowledge • Co-located unrelated modules -
vladikk doit-intl.com #DDDEU High Cohesion LOW STRENGTH HIGH STRENGTH
Local Complexity Loose Coupling LOW DISTANCE HIGH DISTANCE • Low cost of cascading changes • Low shared knowledge • Co-located unrelated modules -
vladikk doit-intl.com #DDDEU High Cohesion LOW STRENGTH HIGH STRENGTH
Local Complexity Loose Coupling ? LOW DISTANCE HIGH DISTANCE • High cost of cascading changes • High shared knowledge • Frequent cascading changes -
vladikk doit-intl.com #DDDEU High Cohesion LOW STRENGTH HIGH STRENGTH
Local Complexity Loose Coupling Global Complexity LOW DISTANCE HIGH DISTANCE • High cost of cascading changes • High shared knowledge • Frequent cascading changes -
vladikk doit-intl.com #DDDEU High Cohesion LOW STRENGTH HIGH STRENGTH
Local Complexity Loose Coupling Global Complexity LOW DISTANCE HIGH DISTANCE -
vladikk doit-intl.com #DDDEU High Cohesion LOW STRENGTH HIGH STRENGTH
Local Complexity Loose Coupling Global Complexity LOW DISTANCE HIGH DISTANCE -
vladikk doit-intl.com #DDDEU 1. Minimize integration strength as much as
possible 2. Balance integration strength and distance • Both are high? — Reduce distance • Both are low? — Increase distance APPLYING M=S^D -
vladikk doit-intl.com #DDDEU 1. Minimize integration strength as much as
possible 2. Balance integration strength and distance • Both are high? — Reduce distance • Both are low? — Increase distance 3. Repeat at all levels of abstraction APPLYING M=S^D -
vladikk doit-intl.com #DDDEU Strength: Contract M=S^D IN DOMAIN-DRIVEN DESIGN
Distance Bounded Context Bounded Context -
vladikk doit-intl.com #DDDEU Strength: Model M=S^D IN DOMAIN-DRIVEN DESIGN
Distance Bounded Context -
vladikk doit-intl.com #DDDEU Implementation Strength M=S^D IN DOMAIN-DRIVEN DESIGN
Distance public class CampaignPublishingSaga { private readonly ICampaignRepository _repository; private readonly IList<IDomainEvent> _events; // ... public void Process(CampaignActivated activated) { var campaign = _repository.Load(activated.CampaignId); var advertisingMaterials = campaign.GenerateAdvertisingMaterials); var commandIssuedEvent = new CommandIssuedEvent( target: Target.PublishingService, command: new SubmitAdvertisementCommand(activated.CampaignId, advertisingMaterials)); _events.Append(activated); _events.Append(commandIssuedEvent); } public void Process(PublishingConfirmed confirmed) { var commandIssuedEvent = new CommandIssuedEvent( target: Target.CampaignAggregate, command: new TrackConfirmation(confirmed.CampaignId, confirmed.ConfirmationId)); _events.Append(confirmed); _events.Append(commandIssuedEvent); } public void Process(PublishingRejected rejected) { var commandIssuedEvent = new CommandIssuedEvent( target: Target.CampaignAggregate, command: new TrackRejection(rejected.CampaignId, rejected.RejectionReason)); _events.Append(rejected); _events.Append(commandIssuedEvent); } } -
vladikk doit-intl.com #DDDEU M=S^D IN DOMAIN-DRIVEN DESIGN public class CampaignPublishingSaga
{ private readonly ICampaignRepository _repository; private readonly IList<IDomainEvent> _events; // ... public void Process(CampaignActivated activated) { var campaign = _repository.Load(activated.CampaignId); var advertisingMaterials = campaign.GenerateAdvertisingMaterials); var commandIssuedEvent = new CommandIssuedEvent( target: Target.PublishingService, command: new SubmitAdvertisementCommand(activated.CampaignId, advertisingMaterials)); _events.Append(activated); _events.Append(commandIssuedEvent); } public void Process(PublishingConfirmed confirmed) { var commandIssuedEvent = new CommandIssuedEvent( target: Target.CampaignAggregate, command: new TrackConfirmation(confirmed.CampaignId, confirmed.ConfirmationId)); _events.Append(confirmed); _events.Append(commandIssuedEvent); } public void Process(PublishingRejected rejected) { var commandIssuedEvent = new CommandIssuedEvent( target: Target.CampaignAggregate, command: new TrackRejection(rejected.CampaignId, rejected.RejectionReason)); _events.Append(rejected); _events.Append(commandIssuedEvent); } } Bounded Context Bounded Context Bounded Context Aggregate -
vladikk doit-intl.com #DDDEU “The most e ff ective tool available
for dealing with complexity is abstraction. Many types of abstraction can be used, but encapsulation is the main form of abstraction by which complexity is managed in object-oriented programming.” - Rebecca Wirfs-Brock -
vladikk doit-intl.com #DDDEU KNOWLEDGE: THE ENERGY OF SOFTWARE DESIGN So
ft ware systems are sustained by the transport of knowledge (energy) through hierarchical networks of modules. -
vladikk doit-intl.com #DDDEU Knowledge (sublinear growth) Complexity (superlinear growth) Cognitive
Limit (No growth) Functionality (Linear growth)