0% found this document useful (0 votes)
26 views

Int Main (Target Target New Adapter

The document describes several design patterns including prototype, adapter, bridge, composite, decorator, abstract factory, factory method and singleton. For each pattern it lists the main participants like client, abstract classes, concrete classes and how they relate to each other and achieve the goals of that particular pattern.

Uploaded by

Nikola
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Int Main (Target Target New Adapter

The document describes several design patterns including prototype, adapter, bridge, composite, decorator, abstract factory, factory method and singleton. For each pattern it lists the main participants like client, abstract classes, concrete classes and how they relate to each other and achieve the goals of that particular pattern.

Uploaded by

Nikola
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Client - creates a new object by asking a prototype to clone itself.

Prototype - declares an interface for cloning itself.

ConcretePrototype - implements the operation for cloning itself.

Target - defines the domain-specific interface that Client uses.

Adapter - adapts the interface Adaptee to the Target interface.

Adaptee - defines an existing interface that needs adapting.

Client - collaborates with objects conforming to the Target interface.

int main() {
Target *target = new Adapter();
target->Request();
delete target;
return 0;

bridge

Abstraction - Abstraction defines abstraction interface.

AbstractionImpl - Implements the abstraction interface using a reference to an object


of type Implementor.

Implementor - Implementor defines the interface for implementation classes. This


interface does not need to correspond directly to abstraction interface and can be very different.
Abstraction imp provides an implementation in terms of operations provided by Implementor
interface.

ConcreteImplementor1, ConcreteImplementor2 - Implements the Implementor


interface.

Composite:
Component - Component is the abstraction for leafs and composites. It defines the interface that
must be implemented by the objects in the composition. For example a file system resource
defines move, copy, rename, and getSize methods for files and folders.
Leaf - Leafs are objects that have no children. They implement services described by the
Component interface. For example a file object implements move, copy, rename, as well as
getSize methods which are related to the Component interface.
Composite - A Composite stores child components in addition to implementing methods
defined by the component interface. Composites implement methods defined in the Component
interface by delegating to child components. In addition composites provide additional methods
for adding, removing, as well as getting components.
Client - The client manipulates objects in the hierarchy using the component interface.

Decorator:
Component - Interface for objects that can have responsibilities added to them
dynamically.

ConcreteComponent - Defines an object to which additional responsibilities can be


added.

Decorator - Maintains a reference to a Component object and defines an interface that


conforms to Component's interface.

Concrete Decorators - Concrete Decorators extend the functionality of the component


by adding state or adding behavior.

Abstract factory

AbstractFactory - declares a interface for operations that create abstract products.

ConcreteFactory - implements operations to create concrete products.

AbstractProduct - declares an interface for a type of product objects.

Product - defines a product to be created by the corresponding ConcreteFactory; it


implements the AbstractProduct interface.

Client - uses the interfaces declared by the AbstractFactory and AbstractProduct classes.

Fabrika* fabrika = new FabrikaNepravilnihOblika();

Oblik* oblik = fabrika->napraviObliOblik();

Factory Method:
Product defines the interface for objects the factory method creates.

ConcreteProduct implements the Product interface.

Creator(also refered as Factory because it creates the Product objects) declares the
method FactoryMethod, which returns a Product object. May call the generating method for
creating Product objects

ConcreteCreator overrides the generating method for creating ConcreteProduct objects

You might also like