Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Advanced oop laws, principles, idioms

5,954 views

Published on


Ever heard of the Law of Demeter? How about the Liskov Substitution Principle? This talk introduces key object-oriented laws and principles currently used in our field and provides guidance for their use when building applications on the .NET platform.

Published in: Technology
  • Be the first to comment

Advanced oop laws, principles, idioms

  1. 1. Advanced OOP Laws  Principles  Idioms Clint Edmonson Senior Consultant Polaris Solutions clinted@polarissoutions.com
  2. 2. Platinum Sponsors Gold Sponsors Silver Sponsors
  3. 3. what is oop?
  4. 4. abstraction encapsulation inheritance polymorphism
  5. 5. structural
  6. 6. domain driven design All software can be composed of only four elements: - Value objects - Entities - Services - Modules
  7. 7. separation of concerns Every class and method should have a single responsibility. All its functionality should be narrowly aligned with that responsibility.
  8. 8. the DRY principle Don’t repeat yourself. Don’t repeat yourself. Don’t repeat yourself.
  9. 9. theory of one right place There should be only one right place for a piece of nontrivial of code, and one right place to make a likely maintenance change.
  10. 10. unit of work Define entity families around transactional boundaries and aggregate root entities.
  11. 11. the open-closed principle Software entities (classes, methods, and modules) should be open for extension but closed for modification.
  12. 12. design by contract Fortify your methods through preconditions, post-conditions, and invariant assertions.
  13. 13. creational
  14. 14. declarative programming Use attributes to describe what you want to happen and leverage a framework will take care of the how.
  15. 15. the provider model Define a public service façade that uses an private implementation to perform all of it’s work.
  16. 16. the provider model code example
  17. 17. inversion of control Hide implementation details by letting subsystems automatically create their objects as they are needed.
  18. 18. inversion of control code example
  19. 19. dependency injection Declaratively describe dependencies between classes and an IOC framework can automatically instantiate all of them.
  20. 20. dependency injection code example
  21. 21. object:relational mapping Leverage IOC and dependency injection to automatically load entities from your database.
  22. 22. behavioral
  23. 23. principle of scenario driven design All functionality should be driven by usage scenarios.
  24. 24. occam’s razor The simplest solution is usually the best.
  25. 25. the pareto principle For many phenomena, 80% of the consequences stem from 20% of the causes
  26. 26. the law of demeter “Don’t talk to your neighbor’s neighbor!” An object should only call methods and properties belonging to: - Itself - Any parameters passed in - Objects it creates - Child components
  27. 27. principle of least resource usage The minimal amount of computational resources should be used to solve a particular need.
  28. 28. principle of least privilege Provide the minimal level of access necessary for consumers to do their job. Combined with the previous principle… Classes and methods should be as stateless and private as possible.
  29. 29. the liskov substitution principle A derived class should be completely and transparently substitutable for it’s base class.
  30. 30. idempotents Transactional systems should allow the same information to be received multiple times without being reprocessed.
  31. 31. cyclomatic complexity The depth of nested logic should be kept to a minimum.
  32. 32. What are your principles?
  33. 33. References Books – – – – – Code Complete - McConnell Domain Driven Design – Evans Effective C# - Wagner Framework Design Guidelines – Cwalina & Abrams Writing Solid Code – Maguire Links – – – – Application Architecture for .NET OO Design Principles Principles of Object Oriented Design SOLID Principles (Wikipedia)
  34. 34. Clint Edmonson Email: clinted@polarissolutions.com Blog: http://www.notsotrivial.net Twitter: @clinted

×