Below steps will show you how to use a design pattern after selecting one:
Read the pattern once through for a overview:
Give importance to the applicability and consequences sections to ensure that the pattern is right for your problem.
Study the structure, participants and collaborations sections:
Make sure to understand the classes and objects in the pattern and how they relate to one another.
Look at the sample code section to see a concrete example of the pattern in action:
Studying the code helps us to implement the pattern.
Choose names for pattern participants that are meaningful in the application context:
The names in the design patterns are too abstract to be directly used in the application. Include the participant name into the name that appears in the application which makes the pattern implementation explicit. For example, if you use strategy pattern for developing UI, use UIStartegy or GridStrategy as class names.
Define the classes:
Declare their interfaces, inheritance relationships and instance variables, which represent the data and objet references. Identify the effected classes by the pattern and modify them accordingly.
Define application-specific names for the operations in the pattern:
Use the responsibilities and collaborations as a guide to name the operations. Be consistent with the naming conventions. For example you can always prefix an operation with “Create-” to denote a factory method.
Implement the operations to carry out the responsibilities and collaborations in the pattern:
The implementation section provides hints to guide us in the implementation. The examples in the sample code section can also help as well.