Design Pattern

Design patterns are reusable solutions for software development. They serve as templates that programmers can use when creating applications. They are not specific to individual programming languages, but instead are best practices or heuristics that can be applied in different programming environments.

While design patterns are not language-dependent, they often include objects or classes. Therefore, they are typically associated with object-oriented programming. Individual patterns can be classified into three different categories: 1) creational patterns, 2) structural patterns, and 3) behavioral patterns.

1. Creational Patterns

Creational design patterns describe ways to create objects using methods that are appropriate for different situations. For example, the "Singleton" pattern is used to create a basic class that will only have one instance. A common example is a global variable defined in the source code of a program. An "Object Pool" pattern is used to create a class with a "pool" of objects that can be retrieved as needed instead of being recreated. This is often used for caching purposes.

2. Structural Patterns

Structural design patterns define the relationships between objects. For example, the "Private Class Data" pattern is used to limit access to a specific class. This can prevent unwanted modification of an object. The "Decorator" class, on the other hand, allows behaviors and states to be added to an object at runtime. This provides programmers with the flexibility to add as many classes to an object as needed. One example is an avatar in a video game that accumulates weapons, armor, and items throughout the game. The appropriately named "Decorator" class would provide a good framework for this process.

3. Behavioral Patterns

Behavioral design patterns describe the behavior of objects, such as the way they communicate with each other. One example is the "Command" pattern, which describes objects that execute commands. The "Memento" pattern records the state of an object so it can be restored to its saved stated. These two patterns can be used together to perform Undo and Redo operations in a program.

Summary

Each of the three categories include several other design patterns that programmers can use. While the patterns provide helpful templates for software developers, they are sometimes criticized for being unnecessary or not specific enough for certain applications. Therefore, while design patterns are useful tools for programming, they do not need to be followed exactly to create a well-designed software program.

Updated July 21, 2016 by Per C.

quizTest Your Knowledge

Which of the following is a Windows API?

A
Win8
0%
B
Win10
0%
C
Win32
0%
D
Win95
0%
Correct! Incorrect!     View the Win32 definition.
More Quizzes →

The Tech Terms Computer Dictionary

The definition of Design Pattern on this page is an original definition written by the TechTerms.com team. If you would like to reference this page or cite this definition, please use the green citation links above.

The goal of TechTerms.com is to explain computer terminology in a way that is easy to understand. We strive for simplicity and accuracy with every definition we publish. If you have feedback about this definition or would like to suggest a new technical term, please contact us.

Sign up for the free TechTerms Newsletter

How often would you like to receive an email?

You can unsubscribe or change your frequency setting at any time using the links available in each email.

Questions? Please contact us.