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.
Subscribe to Startertutorials.com's YouTube channel for different tutorial and lecture videos.
Design Patterns » Introduction » How to use a design pattern
Suryateja Pericherla Categories: Introduction. No Comments on How to use a design pattern
3.8
(8)

Below steps will show you how to use a design pattern after selecting one of them for solving a problem.

 

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.

 


Subscribe to our monthly newsletter. Get notified about latest articles, offers and contests.


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.

How useful was this post?

Click on a star to rate it!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

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

Your email address will not be published. Required fields are marked *