Gang of Fouro Pattern-based design was introducedinto architecture and engineering inthe 1950so It wasnt until a group of fourresearchers combined forces thatpattern-based design became well-known and commonplaceo This group was known as the gang of four (GoF)
Gang of Fouro The gang of four (GoF) is:o Erich Gammao Richard Helmo Ralph Johnsono John Vlissideso They are the authors of the famoustext "Design Patterns: Elements ofReusable Object-Oriented Software"
Pattern??o A pattern is a recurring solution to astandard problem, in a context.o A pattern is a three-part rule, whichexpresses a relation between acertain context, a problem, and asolution.
Design Pattern Advantageso Using patterns offers a few keyadvantages:o Facilitate a proven solutiono Provide a common vocabulary
Types of Patternso Creational patternso Deal with initializing and configuring classes andobjects.o Structural patternso Deal with decoupling interface andimplementation of classes and objectso Composition of classes or objectso Behavioural patternso Deal with dynamic interactions among societiesof classes and objects.o Distribute responsibility.
Creational Design Patternso Abstract Factoryo Factory for building related objectso Buildero Separates an object construction from itsrepresentation.o Factory Methodo Creates an instance of several derived classes.o Prototypeo Factory for cloning new instances from aprototype.o Singletono A class of which a single object can exist.
Structural Patternso Adaptero Match interfaces of different classes.o Bridgeo Separates an Object’s interface from itsimplementation.o Compositeo A tree structure of simple and composite objects.o Decoratoro Add responsibilities of Objects dynamically.o Facadeo A single class that represents the entiresubsystem.
Structural Patterns(Cont.)o Flyweighto A fine-grained objects shared efficientlyo Proxyo An Object representing another Object.
Behavioural Patternso Chain of Responsibilityo Passes a request between a chain of Objects.o Commando Encapsulate a command request as an object.o Iteratoro Elements of a collection are accessedsequentially.o Interpretero Language elements are included.o Mediatoro Defines simplified communication betweenclasses.
Behavioural Patterns(Cont.)o Mementoo Capture and restores an object’s internal state.o Observero A way of notifying change to a number ofclasses.o Stateo Alter an object’s behaviour when its statechanges.o Strategyo Encapsulates an algorithm inside a class.o Template Methodo Defer the exact steps of an algorithm to asubclass.
Behavioural Patterns(Cont.)o Visitoro Defines a new operation to a class withoutchange.
Benefits of Design Patternso Design patterns enable large-scale reuse of softwarearchitectures and also helpdocument systems.o Patterns help improve developercommunication.o Pattern names form a commonvocabulary.o Patterns help ease the transitionto Object Oriented technology.
Drawbacks of Design Patternso Patterns do not lead to directcode reuse.o Patterns are deceptively simple.o Teams may suffer from patternoverload.o Patterns are validated byexperience and discussion ratherthan by automated testing.o Integrating patterns is a human-intensive activity.
Suggestions for Effective Useo Do not recast everything as apatterno Instead, develop strategic domain patterns andreuse existing tactical patterns.o Clearly document when patternsapply and do not apply.o Directly involve pattern authorswith application developers anddomain experts.
Referenceso http://www.dofactory.com/o B. Cheng – Michigan StateUniversity.o http://www.dotnetiq.com/