Presentation is loading. Please wait.

Presentation is loading. Please wait.

Reference – Object Oriented Software Development Using Java - Jia COP 3331 Object Oriented Analysis and Design Chapter 10 – Patterns Jean Muhammad.

Similar presentations


Presentation on theme: "Reference – Object Oriented Software Development Using Java - Jia COP 3331 Object Oriented Analysis and Design Chapter 10 – Patterns Jean Muhammad."— Presentation transcript:

1 Reference – Object Oriented Software Development Using Java - Jia COP 3331 Object Oriented Analysis and Design Chapter 10 – Patterns Jean Muhammad

2 Reference – Object Oriented Software Development Using Java - Jia Overview Abstract Factory Pattern Prototype Pattern Builder Pattern Command Pattern Adapter Pattern Composite Pattern(8.3.2)

3 Reference – Object Oriented Software Development Using Java - Jia Abstract Factory Category: Creational Design Pattern Intent: Provide an interface for creating a family of related or dependent objects without specifying their concrete classes Applicability: Use this pattern when – a system should be created independent of its components or products. – a system should be configurable with one of multiple interchangeable families of products. – a family of related products should not be mixed with similar products from different families. – only the interfaces of the products are exposed, while the implementation of the products is not revealed.

4 Reference – Object Oriented Software Development Using Java - Jia Abstract Factory Participants in the Abstract Factory Pattern: – AbstractFactory – Defines methods that create abstract products. – ConcreteFactory – Implements methods that create concrete methods – AbstractProduct – Defines the interface for a type of product and may provide default implementation – ConcreteProduct – Defines a product to be created by the corresponding concrete factory and implements the AbstractProduct interface. – Client – Uses only AbstractFactory and AbstractProduct

5 Reference – Object Oriented Software Development Using Java - Jia AbstractFactory makeProductA() makeProductB() Client ConcreteFactory1 makeProductA() makeProductB() ConcreteFactory2 makeProductA() makeProductB() AbstractProductA ConcreteProductA1ConcreteProductA2 AbstractProductB ConcreteProductB1ConcreteProductB2

6 Reference – Object Oriented Software Development Using Java - Jia Prototype Category: Creational Design Pattern Intent: To specify the kinds of objects to create using prototypical instance and create new instances by cloning this prototype Applicability: Use this pattern when – a system should be independent of how its components or products are created – the classes to instantiate are specified at run-time – you want to avoid building a class hierarchy of factories that parallels the class hierarchy of products.

7 Reference – Object Oriented Software Development Using Java - Jia Prototype Design Pattern Participants in the Prototype Pattern: – Prototype:which defines interfaces of objects to be created – ConcretePrototype: Implements prototype interface – Client: Creates instances by cloning the prototype.

8 Reference – Object Oriented Software Development Using Java - Jia Client prototype aMethod() Cloneable Prototype clone() ConcretePrototype1 clone() ConcreteProtype2 clone() p = prototype.clone()

9 Reference – Object Oriented Software Development Using Java - Jia Builder Design Pattern Category: Creational Design Pattern Intent: To separate the construction of a complex object from the implementation of its parts so that the same construction process can create complex objects from different implementation of parts Applicability: Use this pattern when – Creating complex objects should be independent of the parts. – the construction process should allow various implementations of the parts used for construction.

10 Reference – Object Oriented Software Development Using Java - Jia Building Pattern Participants in the Builder Pattern: – Builder – Defines interface for creating parts. – ConcreteBiulder – Constructs and assemble parts. – Director – Constructs a product using the Builder interface – Product – Represents the complex object under construction.

11 Reference – Object Oriented Software Development Using Java - Jia Director Product buildProduct() ConcreteBuilder1 buildPart() ConcreteBuilder2 buildPart() Product Builder buildPart()

12 Reference – Object Oriented Software Development Using Java - Jia Command Design Pattern Category: Behavioral Pattern Intent: Encapsulate the action of an object, so that action can be passed as parameters, queued, and possibly undone. Also known as: Action Applicability: Use this pattern when – Actions need to be passed as parameters. – Actions need to be queued and then executed later – Actions may need to be undone

13 Reference – Object Oriented Software Development Using Java - Jia Command Design Pattern Participants in the Command Design Pattern: – Command: Defines an interface to perform or undo an action – Receiver: Knows how to perform the action – ConcreteCommand: Delegates the execution of the action to the Receiver – Client: Creates the concrete commands and binds the concrete commands to their receivers – Invoker: Ask the command to carry out the action

14 Reference – Object Oriented Software Development Using Java - Jia Client Invoker Command execute() ConcreteCommand execute() receiver.action() Receiver action()

15 Reference – Object Oriented Software Development Using Java - Jia Adapter Pattern Category: Structural Design Pattern Intent: Convert the interface of a class into another interface that clients expect Also known as: Wrapper and confused with a bridge Applicability: Use this pattern when – To use an existing class with an interface different from the desired interface

16 Reference – Object Oriented Software Development Using Java - Jia Adapter Pattern Participants in the Adapter Pattern: – Target: Defines the interface used by the client – Client: Uses objects conforming to the Target interface – Adaptee: the existing class to be re-used – Adapter: Which adapts the interface of the Adaptee to Target.

17 Reference – Object Oriented Software Development Using Java - Jia Client Target doTask() Adaptee performTask() Adapter doTask() performTask()

18 Reference – Object Oriented Software Development Using Java - Jia Design Composite Category: Structural Design Pattern Intent: Compose objects into tree structures to represent a part-whole hierarchy. Composite lets clients treat individual objects and composite objects. Applicability: Use this pattern when – you want to represent a part-whole hierarchy of objects. – When you want clients to be able to ignore the difference between composite objects and individual objects.

19 Reference – Object Oriented Software Development Using Java - Jia Composite Design Pattern Participants in the Composite Design Pattern: – Component which declares the common interface for all classes in the composite; implements default behavior common to all classes, as appropriate; and (optionally) defines an interface for accessing a component’s parent in hierarchy. – Leave which defines a behavior for primitive objects. – Composite, which declares an interface for accessing and managing its child compoonents, defines behavior for components having children, stores child components, and implements child- related operations in the Component interface. – Client, which manipulates objects in the composition through the Component interface

20 Reference – Object Oriented Software Development Using Java - Jia Component operation() add(Component) remove(Component) getChild(int) Leaf Operation() Composite operation() add(Component) remove(Component) getChild(int) Client *


Download ppt "Reference – Object Oriented Software Development Using Java - Jia COP 3331 Object Oriented Analysis and Design Chapter 10 – Patterns Jean Muhammad."

Similar presentations


Ads by Google