design patterns
DESCRIPTION
Design Patterns. 1 Paradigm. 4 Concepts. 9 Principles. 23 Patterns. 1 Paradigm. Object-Orientation is good!. Not every-body agrees…. 4 Concepts. The foundations of Object-Orientation Abstraction Encapsulation Inheritance Polymorphism. 9 Principles. - PowerPoint PPT PresentationTRANSCRIPT
4 Concepts
• The foundations of Object-Orientation• Abstraction• Encapsulation• Inheritance• Polymorphism
9 Principles
• Just knowing the four concepts does not make you a good software designer…
• Provide no guidance to design decisions• Concepts are made operational through a
set of of principles for good Object-Oriented design
9 Principles• Isolate the aspects of your application that vary• Program to an interface, not an implementation• Favor composition over inheritance• Strive for loosely coupled designs between interacting objects• Classes should be open for extension, but closed for modification• Depend upon abstractions, not upon concrete classes• Principle of Least Knowledge – only talk to your closest friends• The Hollywood principle – don’t call us, we’ll call you• A class should only have one reason to change
9 Principles
• Where do the principles come from…?
• Accumulated wisdom, learned from solving real-life design problems
• Some obvious…• Some not-so-obvious…• Some overlapping…
9 Principles
• Principles can be used operationally when designing; as guidelines and sanity check
• What problems are we solving when designing software…?
• Examined by the ”Gang of Four” in the 90’es• Erich Gamma, Richard Helm, Ralph Johnson
and John Vlissides
23 Patterns
• Authors examined a large base of high-quality code, to identify how common software design problems were solved
• No theoretical work; pattens are discovered, not invented
• 23 common strategies for solving design problems were identified, and dubbed design patterns
23 Patterns
• Design patterns fall in three categories– Creational: How are objects created– Structural: How are objects combined– Behavioral: How do objects interact
23 Patterns• Behavioral patterns
– Chain of responsibility– Command– Interpreter– Iterator– Mediator– Memento– Observer– State– Strategy– Template Method– Visitor
Design Patterns
• Are distilled knowledge• Learned from practical experience• Solve a problem in a given context• Provides a common vocabulary• Is not the solution to all SW design issues…• …but almost