Successfully reported this slideshow.
DDD with C# 3.0 features: Solar System Simulation Andre Boonzaaijer, Pieter-Joost van de Sande {aboonzaaijer, pjvdsande}@s...
Today’s agenda <ul><li>DDD – short intro </li></ul><ul><li>Case: Problem definition </li></ul><ul><li>Case: C# (2.0) solut...
What is “Domain Driven”?
It’s not: Layering Presentation Layer Data Layer
Layering Presentation Layer Data Layer Business logic
Layering Presentation Layer Data Layer Business logic
Layering Presentation Layer Data Layer Business logic
Layering Presentation Layer Data Layer Business logic +/- 2 years
Layering Presentation Layer Data Layer Business logic +/- 2 years +/- 5 years
Layering Presentation Layer Data Layer Business logic +/- 2 years +/- 5 years ?
Layering Presentation Layer Data Layer Business logic Email SMS Printing Email Where?
Layering Presentation Layer Data Layer Business logic
Sunflower
Case… <ul><li>Build a runnable solar system simulator </li></ul><ul><ul><li>1 star in the centre </li></ul></ul><ul><ul><l...
Gravity (x,y) force = 0; Foreach body in universe force += body.getForce(x,y); body.move(force);
Domain
Wrapping the domain User Interface Clock Database Bootstrapper / Host
User Interface
Clock <ul><li>Standard implementation </li></ul><ul><li>Configurable interval </li></ul><ul><li>Start(), Stop(), Tick even...
Database <ul><li>O/R bridging </li></ul><ul><ul><li>Table per domain class </li></ul></ul><ul><ul><li>Column for public pr...
Bootstrap <ul><li>Instantiation (create form, clock and universe components) </li></ul><ul><li>Event subscription  </li></ul>
Domain in C# 3.0
Domain in C# 3.0
Universe class Methods <ul><li>TimerPassed() method </li></ul><ul><li>- ‘Classic’ </li></ul><ul><li>- Lambda: </li></ul>
Universe class Methods <ul><li>GetPlanetsInRange() Method </li></ul>
Universe class Methods <ul><li>GetPlanetsInRange() Method: Lambda </li></ul>
Universe class Methods <ul><li>GetPlanetsInRange() Method: LINQ </li></ul>
Form1 class Methods DrawUniverse:  Who is responsible? UI.DrawUniverse() vs Universe.Draw()
Universe.Draw() Extension
Universe.Draw() Extension
Extension Methods: How <ul><li>Add a Static class to your namespace </li></ul><ul><li>Add static methods for each extensio...
Refences <ul><li>DDD Masterclass ( http://domaindrivendesign.nl ) </li></ul><ul><li>Rebecca Wirfs-Brock: Object Design </l...
Domain Driven Design In C#3.0
Upcoming SlideShare
Loading in …5
×

Domain Driven Design In C#3.0

2,707 views

Published on

Published in: Business, Technology

Domain Driven Design In C#3.0

  1. 1. DDD with C# 3.0 features: Solar System Simulation Andre Boonzaaijer, Pieter-Joost van de Sande {aboonzaaijer, pjvdsande}@sogyo.nl http://born2code.net | http://whiletrue.nl | http://sogyo.nl
  2. 2. Today’s agenda <ul><li>DDD – short intro </li></ul><ul><li>Case: Problem definition </li></ul><ul><li>Case: C# (2.0) solution </li></ul><ul><li>Case: C# 3.0 extensions </li></ul><ul><li>Demo </li></ul>
  3. 3. What is “Domain Driven”?
  4. 4. It’s not: Layering Presentation Layer Data Layer
  5. 5. Layering Presentation Layer Data Layer Business logic
  6. 6. Layering Presentation Layer Data Layer Business logic
  7. 7. Layering Presentation Layer Data Layer Business logic
  8. 8. Layering Presentation Layer Data Layer Business logic +/- 2 years
  9. 9. Layering Presentation Layer Data Layer Business logic +/- 2 years +/- 5 years
  10. 10. Layering Presentation Layer Data Layer Business logic +/- 2 years +/- 5 years ?
  11. 11. Layering Presentation Layer Data Layer Business logic Email SMS Printing Email Where?
  12. 12. Layering Presentation Layer Data Layer Business logic
  13. 13. Sunflower
  14. 14. Case… <ul><li>Build a runnable solar system simulator </li></ul><ul><ul><li>1 star in the centre </li></ul></ul><ul><ul><li>Configurable amount of planets (mass is max 1% of the star’s mass) </li></ul></ul><ul><ul><li>Laws of physics: </li></ul></ul><ul><ul><ul><li>F = M * a </li></ul></ul></ul><ul><ul><ul><li>Fg = M1*M2 / d^2 </li></ul></ul></ul><ul><ul><li>Starting point: Random generated </li></ul></ul><ul><li>Draft a domain model. </li></ul>
  15. 15. Gravity (x,y) force = 0; Foreach body in universe force += body.getForce(x,y); body.move(force);
  16. 16. Domain
  17. 17. Wrapping the domain User Interface Clock Database Bootstrapper / Host
  18. 18. User Interface
  19. 19. Clock <ul><li>Standard implementation </li></ul><ul><li>Configurable interval </li></ul><ul><li>Start(), Stop(), Tick event </li></ul>
  20. 20. Database <ul><li>O/R bridging </li></ul><ul><ul><li>Table per domain class </li></ul></ul><ul><ul><li>Column for public properties (discussion) </li></ul></ul><ul><ul><li>Associations converted to foreign keys </li></ul></ul>?
  21. 21. Bootstrap <ul><li>Instantiation (create form, clock and universe components) </li></ul><ul><li>Event subscription </li></ul>
  22. 22. Domain in C# 3.0
  23. 23. Domain in C# 3.0
  24. 24. Universe class Methods <ul><li>TimerPassed() method </li></ul><ul><li>- ‘Classic’ </li></ul><ul><li>- Lambda: </li></ul>
  25. 25. Universe class Methods <ul><li>GetPlanetsInRange() Method </li></ul>
  26. 26. Universe class Methods <ul><li>GetPlanetsInRange() Method: Lambda </li></ul>
  27. 27. Universe class Methods <ul><li>GetPlanetsInRange() Method: LINQ </li></ul>
  28. 28. Form1 class Methods DrawUniverse: Who is responsible? UI.DrawUniverse() vs Universe.Draw()
  29. 29. Universe.Draw() Extension
  30. 30. Universe.Draw() Extension
  31. 31. Extension Methods: How <ul><li>Add a Static class to your namespace </li></ul><ul><li>Add static methods for each extension </li></ul><ul><li>Add a ‘this’ parameter to the ext. method </li></ul>
  32. 32. Refences <ul><li>DDD Masterclass ( http://domaindrivendesign.nl ) </li></ul><ul><li>Rebecca Wirfs-Brock: Object Design </li></ul><ul><li>Eric Evans: Domain Driven Design </li></ul><ul><li>Blogs </li></ul><ul><ul><li>http://born2code.net </li></ul></ul><ul><ul><li>http://whiletrue.nl </li></ul></ul><ul><ul><li>http://software-innovators.nl </li></ul></ul>

×