Design Patterns 1 | Introduction
Published: 2022-08-31 08:01:48


In software development, design patterns are solutions to recurring software design problems. They can also be referred to as descriptions or templates for solving commonly occurring problems.

Design patterns are often created for and used by object oriented programming languages. It should be noted that they are not finished designs that can be transformed directly into source or machine code. 

## A real world example

Since we have explained what design patterns are, now lets make it easier to understand with a nondevelopmental, real life scenario.

You’re the proud owner of a gardening company, and your business is really blooming. You’ve only done a few small projects up to now - a tree planted here and a few flowers there. However, you just landed a big client who wants several dozen trees and flowers planted on their property.

Your standard procedure has been for your employees to carry each flower or tree sapling into place individually. Once each has been temporarily placed, your customer inspects and approves the arrangement before you plant everything in the ground.

You’re worried it’s going to take forever to carry each flower and tree into place for this large project. And you even need a few people to carry some of the bigger trees. While you could hire lots of temporary employees, you wouldn’t make a profit on the job. There’s got to be a better way!

You decide to ask other gardeners what they do, and you find out they use wheelbarrows and carts. What a great idea! You tell your employees to use a cart to move multiple flowers at the same time and a wheelbarrow to move the heavy trees. In the meantime, you use a lounge chair to watch your workers go to it… isn’t management great?

Now let’s break it down.

## Example explanation

The “design pattern” here is the use of wheelbarrows and carts. These are common, best practice tools in gardening. Similarly, software design patterns form a set of best practices in development. You could have chosen not to use wheelbarrows and carts, but similar to avoiding software design patterns, you assume more risk by making the project more time and labor intensive.

Back to the point of “asking other gardeners what they do”, Most design patterns have been around for a long time and they continue to work well to this day.

This longevity is partly due to the fact that their use has been validated in many projects over the decades, but it’s also because they aren’t concrete solutions.

In the gardening scenario, you decided that carts will be used to move flowers and wheelbarrows will be used to move trees. These are implementation details, you could have used carts to move both flowers and trees, only used wheelbarrows, or any other combination that made the job easier.

Design patterns are generic, go-to solutions for solving common problems, like using wheelbarrows and carts. They are starting points for concrete implementations, like using carts for flowers and wheelbarrows for trees.

Make sense? Great! It’s now time to leave the garden behind and head back to the world of software design patterns in the [next article](https://dev.to/abdulhameedanofi/design-patterns-2-types-1jgk).