11.10.2013 Views

Design Patterns

Design Patterns

Design Patterns

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Structure<br />

Product<br />

ConcreteProduct<br />

<br />

61<br />

Creator<br />

FactoryMethod()<br />

AnOperation()<br />

ConcreteCreator<br />

FactoryMethod()<br />

AnOperation()<br />

APPLICATION OF THE FACTORY METHOD PATTERN<br />

Files<br />

Open()<br />

Close()<br />

Save()<br />

<br />

Text−File OpenOffice<br />

63<br />

Application<br />

CreateFiles()<br />

NewFiles()<br />

OpenFiles()<br />

CreateFiles()<br />

Participants<br />

• Product (Files)<br />

– defines the interface of objects the FactoryMethod() creates<br />

• ConcreteProduct (Text-File)<br />

– implements the Product interface<br />

• Creator (Application)<br />

– declares the FactoryMethod(), which returns an object of type<br />

Product<br />

• ConcreteCreator (Open Office)<br />

– overrides the FactoryMethod() to return an instance of a<br />

ConcreteProduct<br />

Related <strong>Patterns</strong> Abstract Factory, Template Method, Prototypes<br />

WHAT HAVE WE LEARNT?<br />

➠ <strong>Design</strong> patterns are object oriented patterns at detailed design level.<br />

➠ They are closer to implementation than architectural styles.<br />

➠ According to the GoF classification, there are behavioral, creational and<br />

structural patterns.<br />

➠ <strong>Design</strong> patterns support achieving desirable properties in implementing<br />

62<br />

object-oriented software, e.g. independent modification of parts, limitation<br />

of communication paths etc.<br />

64

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!