Introduction to UML
Before i start discussing Design Patterns, i like to give a small introduction about Unified Modeling Language(UML).
It is a good design to prepare UML before you start coding. It's very easy to learn UML, i will continue guiding you the UML in simple steps:
Symbols to follow as prefix for classes, variables, access specifiers and methods.
i) default will be prefix by (~)
ii) private will be prefix by (-)
iii) public will be prefix by (+)
iv) protected will be prefix by (#)
v) abstract class,variables & methods must be in italics
vi) static variables & methods must be underlined
I will continue the presentation in the next section, thanks for your time
Creational design pattern tries to reduce the creational complexities (of an object) at its maximum level.
Factory Pattern:
One of the goals of object-oriented design is to delegate responsibility among different objects.A class may need it’s subclasses to specify the objects to be created or delegate responsibility to one of several helper subclasses so that knowledge can be localized to specific helper subclasses.
The Factory patterns can be used in following cases:
1 When a class does not know which class of objects it
must create.
2 A class specifies its sub-classes to specify which
objects to create.
3 In programmer’s language (very raw form), you can use
factory pattern where you have to create an object of
any one of sub-classes depending on the data provided.