Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this


  1. 1. Antonio Radesca http://dotnetslackers.com/Community/blogs/antrad/ Domain Driven Design
  2. 2. <ul><li>Business Requirement <>Business Modeling<>Software Design </li></ul>Business Modeling Software Design Order Customer Product 1..* Domain Model Process (text)‏ Business Requirement
  3. 4. <ul><li>DDD is a set of mindset,principles and practices for support software design related to complex domains </li></ul><ul><li>We must use DDD because software implementation is often very different from its initial description </li></ul><ul><li>DDD try to link model and design ever </li></ul><ul><li>Formalized by Eric Evans in “ Domain Driven Design: Tackling Complexity In The Heart Of Software ” </li></ul>
  4. 5. <ul><li>Software development is knowledge of the subject matter </li></ul><ul><li>Software is different from analisys model </li></ul><ul><li>Some information is not expressed </li></ul><ul><li>Analisys model fails because crucial discoveries emerge during design/coding effort </li></ul>
  5. 6. <ul><li>Ubiquitous Language </li></ul><ul><li>Design practices and patterns </li></ul>
  6. 7. <ul><li>Model is a set od concepts expressed as words and relations used for improve comunications between stakeholders </li></ul><ul><li>Jargon domain experts<> Jargon developers </li></ul><ul><li>DM provides language for communication between domain experts and developers </li></ul><ul><li>Terms of UL come from DM </li></ul><ul><li>Ubiquitous language force finding common problems in problem resolution </li></ul><ul><li>Use DM as backbone of language </li></ul><ul><li>UL must be used in speechs and diagrams too </li></ul>
  7. 8. <ul><li>Changes to UL are changes to DM </li></ul><ul><li>DM with UL is a design artifact and is shared from domain experts and developers </li></ul><ul><li>Describing scenarios is the best practice </li></ul><ul><li>Recognizing problems is more simple </li></ul>
  8. 9. <ul><li>UML is very good but fails in some things </li></ul><ul><li>Object diagram shows attibutes and relationship very good but there are not so much information about behaviour of components </li></ul><ul><li>We can use sequence diagram but text and conversations are the most powerfull instruments </li></ul><ul><li>UML fails in:meaning of concepts it represents (states) and what the objects are meant to do. </li></ul><ul><li>COMMUNICATION BASED ON UL AND MODEL </li></ul>Ubiquitous language and Documentation
  9. 10. <ul><li>A document shouldn’t try to do what the code already does well </li></ul><ul><li>Documents must explane concepts of model </li></ul><ul><li>Help in navigating code </li></ul><ul><li>UL helps documents </li></ul><ul><li>Concise and less amiguous </li></ul><ul><li>Requirements become scenarios </li></ul>DDD, documents and diagrams
  10. 11. <ul><li>Diagrams are a means of communication and explanation </li></ul><ul><li>They serve these ends if they are minimal </li></ul><ul><li>They represent the skeletons of ideas </li></ul><ul><li>Model<>Diagram </li></ul><ul><li>Diagram communicate and explane model </li></ul><ul><li>Documents and diagrams must complement code and speechs </li></ul><ul><li>The vital details are capturated into CODE! </li></ul>
  11. 12. Cargo cargoId origin destination Routing service Origin Destination Populate Cargo DB table:cargo_booking Cargo_Id,Transport,Load,Unload
  12. 13. Routing Service A Route Specification An Itinerary satisfyting the Route specification
  13. 15. <ul><li>MDD support DDD </li></ul><ul><li>Structure software around some set of concepts </li></ul><ul><li>Example: </li></ul><ul><li>UI Framework is developed as UI concepts (menu,windows for example) and corrisponds to actual software construct </li></ul><ul><li>Design <>Model=Software not correct </li></ul><ul><li>MDD discard Analisys Model </li></ul><ul><li>Mapping between model and design </li></ul>
  14. 16. <ul><li>Modeling and design will be a single iterative loop </li></ul><ul><li>Model is revisited to be implemented more naturally in software </li></ul><ul><li>Code will be an expression of model </li></ul><ul><li>Correspondence will be literal </li></ul><ul><li>This is more effective using OOP </li></ul>
  15. 17. Layering User Interface (Presentation Layer)‏ Responsible for presenting information to the user and interpreting user commands. Application Layer This is a thin layer which coordinates the application activity. It does not contain business logic. It does not hold the state of the business objects, but it can hold the state of an application task progress. Domain Layer This layer contains information about the domain. This is the heart of the business software. The state of business objects is held here. Persistence of the business objects and possibly their state is delegated to the infrastructure layer. Infrastructure Layer This layer acts as a supporting library for all the other layers. It provides communication between layers, implements persistence for business objects, contains supporting libraries for the user interface layer, etc.
  16. 18. <ul><li>Entity </li></ul><ul><li>Value Object </li></ul><ul><li>Service </li></ul><ul><li>Repository </li></ul><ul><li>Aggregates </li></ul><ul><li>Factory </li></ul>
  17. 20. Defines an application's boundary with a layer of services that establishes a set of available operations and coordinates the application's response in each operation. A service typically implements a business rule, generally something that software must do. Infrastructure and domain logic services A Service Layer defines an application's boundary [Cockburn PloP] and its set of available operations from the perspective of interfacing client layers. It encapsulates the application's business logic, controlling transactions and coor-dinating responses in the implementation of its operations.
  18. 22. Mediates between the domain and data mapping layers using a collection-like interface for accessing domain objects. A Repository encapsulates the set of objects persisted in a data store and the operations performed over them, providing a more object-oriented view of the persistence layer. Repository also supports the objective of achieving a clean separation and one-way dependency between the domain and data mapping layers.
  19. 24. <ul><li>Aggregate is a cluster of associated objects that we treat as a unit for the purpose of data changes. </li></ul><ul><li>Each aggregate has a root and a boundary </li></ul>
  20. 25. Creates and manage complex objects. Abstract Factory Provides an interface for creating families of related or dependent projects without specifying their concrete classes.
  21. 26. <ul><li>A good design helps to mantain project in consistent state and integrity model. </li></ul>
  22. 27. <ul><li>Bounded Context delimits the applicability of a particular model. </li></ul><ul><li>Sets boundaries of team organization,usage of specific parts of application and physical (code,db,etc)‏ </li></ul>
  23. 28. Next time…. :D
  24. 29. <ul><li>Describe the points of contact between the models… </li></ul><ul><li>Express models relationship </li></ul><ul><li>Overlap between project management and software design </li></ul><ul><li>Helps communication between teams </li></ul><ul><li>UL by different teams must be shared </li></ul><ul><li>Map the existing terrain.Take up trasformations later. </li></ul>
  25. 30. <ul><li>Part of the system that is shared from 2 or more teams </li></ul><ul><li>Part of the system that cannot be changed freely as other parts of the system </li></ul><ul><li>Decisions involve consultation with an another team </li></ul><ul><li>Automatic tests must be integrated by teams </li></ul>
  26. 31. <ul><li>Large systems have many interfaces with others </li></ul><ul><li>An isolation layer talks to others throught its existing interface requiring little or no modifications to other systems </li></ul><ul><li>It is not a system for send messages </li></ul><ul><li>It is a mechanism that translates conceptual objects and actions from one model and protocol to an other </li></ul><ul><li>Sometimes is a complex part of a software </li></ul><ul><li>Often is designed as a set of services </li></ul><ul><li>Use some patterns (FACADE,Adapter)‏ </li></ul>
  27. 32. A little bit…. :D
  28. 33. ORM SOA Patterns Refactoring TDD IOC
  29. 35. Resolve the problem of paradigm mismatch!!! Data Mapper A layer of Mappers (473) that moves data between objects and a database while keeping them independent of each other and the mapper itself.
  30. 36. Linq To SQL Entity Framework NHibernate
  31. 38. Very simple please… :D