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

The Fractal Geometry of Software Design

The Fractal Geometry of Software Design

Presented at Domain-Driven Design Europe 2022 (Keynote)

Vladik Khononov

June 24, 2022
Tweet

More Decks by Vladik Khononov

Other Decks in Technology

Transcript

  1. vladikk doit-intl.com #DDDEU • How much food do we need

    to stay alive? • How creative are we? • How profitable are our companies?
  2. 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?
  3. 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.
  4. 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.
  5. 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
  6. 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?
  7. 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?
  8. vladikk doit-intl.com #DDDEU West, G. (2018). Scale: The universal laws

    of life and death in organisms, cities and companies. Weidenfeld & Nicolson.
  9. 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.
  10. 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?
  11. 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
  12. 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
  13. vladikk doit-intl.com #DDDEU ENERGY SUPPLY NETWORKS Systems that are sustained

    by the transport of energy through hierarchical networks.
  14. vladikk doit-intl.com #DDDEU KNOWLEDGE: THE ENERGY OF SOFTWARE DESIGN Implementation

    Coupling Functional Coupling Model Coupling Contract Coupling
  15. 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
  16. 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
  17. 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
  18. 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
  19. 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)
  20. 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
  21. 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.
  22. vladikk doit-intl.com #DDDEU West, G. (2018). Scale: The universal laws

    of life and death in organisms, cities and companies. Weidenfeld & Nicolson.
  23. vladikk doit-intl.com #DDDEU West, G. (2018). Scale: The universal laws

    of life and death in organisms, cities and companies. Weidenfeld & Nicolson.
  24. 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.
  25. 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.
  26. 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.
  27. vladikk doit-intl.com #DDDEU y = 3.4 * x3/4 y =

    x Sublinear 
 Growth Linear 
 Growth Sublinear function grows slower than any linear function
  28. 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
  29. 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
  30. 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
  31. 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
  32. vladikk doit-intl.com #DDDEU West, G. (2018). Scale: The universal laws

    of life and death in organisms, cities and companies. Weidenfeld & Nicolson.
  33. 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.
  34. 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.
  35. vladikk doit-intl.com #DDDEU y = x1.15 y = x Superlinear

    
 Growth Linear 
 Growth Superlinear function grows faster than any linear function
  36. 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.
  37. 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
  38. 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
  39. 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 ?
  40. 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.
  41. 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
  42. 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
  43. vladikk doit-intl.com #DDDEU POSTPONING GROWTH LIMITS 1. Adapt form /

    shape to withstand increased stress 2. Use stronger materials
  44. 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
  45. 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
  46. vladikk doit-intl.com #DDDEU "Technology can bring benefits if, and only

    if, it diminishes a limitation’" - Eliyahu M. Goldratt
  47. 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
  48. vladikk doit-intl.com #DDDEU Knowledge (sublinear growth) Complexity (superlinear growth) Cognitive

    Limit (No growth) Functionality (Linear growth) Cognitive Limit (superlinear growth)
  49. 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
  50. 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
  51. 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.
  52. vladikk doit-intl.com #DDDEU https://opte.org Klinkhamer, Christopher, et al. "Functionally fractal

    urban networks: Geospatial co-location and homogeneity of infrastructure."
  53. 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
  54. 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
  55. vladikk doit-intl.com #DDDEU Knowledge (sublinear growth) Complexity (superlinear growth) Cognitive

    Limit (No growth) Functionality (Linear growth) Complexity Sublinear growth)
  56. 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
  57. 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.
  58. vladikk doit-intl.com #DDDEU Y. Chen, P. Cheng, Heat transfer and

    pressure drop in fractal tree-like microchannel nets
  59. vladikk doit-intl.com #DDDEU INTEGRATION STRENGTH (S) Implementation Coupling Functional Coupling

    Model Coupling Contract Coupling Shared Knowledge Encapsulated 
 Knowledge Boundaries Encapsulated 
 Knowledge
  60. vladikk doit-intl.com #DDDEU DISTANCE (D) M ethods Classes Sub-M odules

    M odules Com ponents (M icro)Services System s Coordination
  61. vladikk doit-intl.com #DDDEU LOW STRENGTH HIGH STRENGTH ? LOW DISTANCE

    HIGH DISTANCE • High cost of cascading changes • Low shared knowledge • Minimizes cascading changes
  62. 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
  63. 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
  64. 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
  65. 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
  66. 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
  67. 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
  68. 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
  69. vladikk doit-intl.com #DDDEU High 
 Cohesion LOW STRENGTH HIGH STRENGTH

    Local 
 Complexity Loose Coupling Global 
 Complexity LOW DISTANCE HIGH DISTANCE
  70. vladikk doit-intl.com #DDDEU High 
 Cohesion LOW STRENGTH HIGH STRENGTH

    Local 
 Complexity Loose Coupling Global 
 Complexity LOW DISTANCE HIGH DISTANCE
  71. 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
  72. 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
  73. 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); } }
  74. 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
  75. 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
  76. 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.