4.1 Introduction

Introduction to Design Patterns

It is very often that, when designing software, that a large portion of the software we need to develop is something quite common which has been done before, again and again. Design Patterns are standardized best practice "template solutions" for common programming problems. They allow us to simply apply a "cookie cutter" approach to software design, allowing us the peace of mind that when we apply one of the many design patterns, that we are solving the particular design problem in a tried and tested way.

Design Patterns are typically categorized into one of the following broad categories:

  1. Creational Patterns: Design Patterns concerning object creation.
  2. Structural Patterns: Design Patterns concerned with the composition and structure of objects.
  3. Behavioral Patterns: Design Patterns which characterize the way in which objects interact and distribute responsibility.

Each Design Pattern is defined in terms of the following four componenets:

  1. Pattern Name: The name of the design pattern.
  2. Problem Statement: A description of the problem which the pattern provides a solution for.
  3. Solution: A description of the elements, relationships, behaviors and interactions which provides a solution to the problem statement.
  4. Consequences: The results and trade-offs of utilizing the design pattern.

In this module, we will not be covering all design patterns, but rather, we will cover a few patterns per category, showing how to implement them in Python. The intention is to get the learner familiar with using Design Patterns, so that the learner can lookup other design patterns and be able to utilize them on their own in their projects.

For a list of Design Patterns, you can take a look at oodesign.com, and for more background on Design Patterns, take a look at the Wikipedia entry.

Continue to next section.


Comments

comments powered by Disqus