lecture 5 & 6: March 2006
Continuation of Creational patterns
Buider , prototype, Singleton and Factory Method Design patterns
Buider Design Pattern is used in the creation of a very complex object, though the representation is hidden from the client. The same process used in the creation of the object can be used again in the creation of other objects.
Take the Bicycle Assembly plant ,for example. Such a plant uses the buider pattern in the construction of of its bicycles, as there are different parts which make up a bicycle, such as tyres, sadle, peddle etc. even if the parts and the process used in the creation of the bicycles are the same, there are different types of bicycles that they also make such as Mountain bikes , sporting bikes and ordinary bikes.
The buider is a good pattern because it supports modularity, in the building of complex objects, and modlarity has various advantages including the ease of debugging.
Factory method provides an option to choose(choice) to the subclasses of the objects to institiate at runtime. factory does not have a family of products like the abstract factory.
Prototype
Its a pattern that uses the theory of "Copy and paste", i.e. it creates new objects by copying/cloning after specifying the kind of object to be created. The catch is that the objects to be cloned should be similar, that you dont have to create all the time. it behaves like a template, for example a college will have the same letter for enrolment for all students with the difference being the date and the name of the student. But the same letter is copied for the next student who wants the letter.
Singleton
a class of which only a single instance can exist.An example of a singleton would be, in the real world situation,take in a soccer match, a goal post will only be managed by a single goal keeper for a match.
The singleton will work very well in a stand alone environment but might prove to be mulfanctioning in the even when it is incorporated with other programs.
further reading: www.dofactory.com/Patterns/Patterns.aspx
References:
Gamma, E., Helm, R., Johnson R., & Vlissides, J. (1995) Design Patterns: elements of reusable software, Addison Wesley, ("Gang of Four Book (GoF)") pg 97 - 134
Continuation of Creational patterns
Buider , prototype, Singleton and Factory Method Design patterns
Buider Design Pattern is used in the creation of a very complex object, though the representation is hidden from the client. The same process used in the creation of the object can be used again in the creation of other objects.
Take the Bicycle Assembly plant ,for example. Such a plant uses the buider pattern in the construction of of its bicycles, as there are different parts which make up a bicycle, such as tyres, sadle, peddle etc. even if the parts and the process used in the creation of the bicycles are the same, there are different types of bicycles that they also make such as Mountain bikes , sporting bikes and ordinary bikes.
The buider is a good pattern because it supports modularity, in the building of complex objects, and modlarity has various advantages including the ease of debugging.
Factory method provides an option to choose(choice) to the subclasses of the objects to institiate at runtime. factory does not have a family of products like the abstract factory.
Prototype
Its a pattern that uses the theory of "Copy and paste", i.e. it creates new objects by copying/cloning after specifying the kind of object to be created. The catch is that the objects to be cloned should be similar, that you dont have to create all the time. it behaves like a template, for example a college will have the same letter for enrolment for all students with the difference being the date and the name of the student. But the same letter is copied for the next student who wants the letter.
Singleton
a class of which only a single instance can exist.An example of a singleton would be, in the real world situation,take in a soccer match, a goal post will only be managed by a single goal keeper for a match.
The singleton will work very well in a stand alone environment but might prove to be mulfanctioning in the even when it is incorporated with other programs.
further reading: www.dofactory.com/Patterns/Patterns.aspx
References:
Gamma, E., Helm, R., Johnson R., & Vlissides, J. (1995) Design Patterns: elements of reusable software, Addison Wesley, ("Gang of Four Book (GoF)") pg 97 - 134
0 Comments:
Post a Comment
<< Home