Design Patterns Tutorial
A tutorial on GOF design patterns. This tutorial is for beginners who are going to learn design patterns for the first time. Each pattern is expalined with suitable examples.

15/11/2013 Categories: Introduction. No Comments on How to use a design pattern

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.

Related Links:

Note: Do you have a question on this article or have a suggestion to make this article better? You can ask or suggest us by filling in the below form. After commenting, your comment will be held for moderation and will be published in 24-48 hrs.

Leave a Reply

Scroll Up