Design Patterns v1 0
Design Patterns v1 0
Management System
Agenda
OOAD UML
Thinking in Objects Design Patterns
ICONIX Process
Key Terms
Requirement Type
Functional Non-Functional
Analysis
Investigation of problem and requirement rather than a solution (Understanding requirement) Do the right thing
Design
Conceptual solution to a problem Do thing right
OOAD
Thinking in Objects
Difference between Class and Object
Thinking in Objects
Coupling
Strength of association from one object to other
Cohesion
Degree of connectivity between the elements of class or object
UML
A general-purpose notational language for specifying and visualizing complex software, especially object-oriented systems Perspectives to Apply UML
Conceptual perspective the diagrams are interpreted as describing things in a situation of the real world or domain of interest. Specification (Software) perspective the diagrams describe software abstractions or components with specifications and interfaces, but no commitment to a particular implementation. Implementation (Software) perspective the diagrams describe software implementation in a particular technology.
Design
Frameworks
OOAD
S/w Engineering
UML
Programming Language
Design Patterns
***
OOAD UML - Design Patterns: Relationship
10
Design Patterns
Pattern
new context
Someone has already solved the problem
Patterns dont give you code, they give you general solutions to design problems Design patterns dont go directly into your code, they go into your BRAIN Design thinks about how to create flexible designs that are maintainable and that can cope with CHANGE CHANGE IS CONSTANT Design should Open for extension and close for modification A class should have only one responsibility Identify the aspects that vary and separate then from what stays the same Program for an Interface, not an implementation Favor composition over inheritance [Delegation vs Inheritance] Composition change behavior at Runtime Has a (Composition) vs. Is a (Inheritance) relation
12
Creational Patterns deal with initializing and configuring classes and objects how am I going to create my objects? Structural Patterns deal with decoupling the interface and implementation of classes and objects how classes and objects are composed to build larger structures Behavioral Patterns deal with dynamic interactions among societies of classes and objects how to manage complex control flows (communications)
13
Purpose
Creational
Class
Structural
Adapter Adapter Bridge Composite Decorator Facade Flyweight Proxy
Behavioral
Interperter Chain of Responsibility Command Iterator Mediator Momento Observer State Strategy Vistor
Scope Object
14
1.
2.
3.
Singleton Pattern
4.
Builder Pattern
5.
Prototype Pattern
15
Intent (Objective) -
Intent (Objective) -
Provides an interface for creating families of related or dependent objects without specifying their concrete classes
17
3. Singleton Pattern
Intent (Objective) Ensures a class has only one instance, and provide a global point of access to it Private/protected constructor & static method javax.net.ServerSocketFactory
18
1. 2. 3. 4. 5. 6. 7.
Adapter Pattern (Class) Faade Pattern Composite Pattern Bridge Pattern Decorator Pattern Proxy Pattern Flyweight
19
1. Adapter Pattern
Intent (Objective)
Composition
20
2. Faade Pattern
Intent (Objective) Provides a unified interface to a set of interfaces in a subsystem. Faade defines a higher level interface that makes the subsystem easier to use. Ex. Remote control
21
3. Composite Pattern
Intent (Objective) -
Composite lets client treat individual objects and composition of objects uniformly. Menu MenuItem
22
4. Bridge
Intent (Objective) -
vary independently
23
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11.
Observer Pattern (Class) Strategy Pattern Command Pattern State Pattern Template Method Pattern Iterator Pattern Mediator Pattern Memento Pattern Visitor Pattern Chain Of Responsibility Pattern Interpreter Pattern (Class)
24
1. Observer Pattern
Intent (Objective) Defines a one-to-many dependency between objects so that when one object changes state, all of its dependents are notified and updated automatically. Ex. Button Action Listener, Mouse Listener
java.uitl.Observer, Observable
25
2. Strategy Pattern
Intent (Objective) Defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it. Change behavior at runtime.
Intent (Objective) Defines the skeleton of an algorithm in a method, deferring some steps to subclass. Template Method let subclass redefine certain steps of an algorithm without changing the algorithms structure.
4. State Pattern
Intent (Objective) -
28
5. Iterator Pattern
Intent (Objective) -
29
6. Chain Of Responsibility
Intent (Objective)
Avoid coupling (decouples) the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it Allows you to add or remove responsibilities dynamically by changing the members or order of the chain
31
32
33
Robustness (Analysis) Diagrams Close the Gap Between Requirements and Detailed Design
34
Referencing Domain Objects by Name Removes Ambiguity from the Use Cases
35
36
?
37
Thank You!