What are Design Patterns in programming and why they are important?

What are Design Patterns in programming and why they are important?

Published Date: 1/27/2020

Design Patterns is the practice of designing object-oriented software in such a way that are reusable and extensible. The term Reusable simply means that a function should be implemented once and reused everywhere without duplicating code. Extensible means that we should be able to add functionality (extend) without breaking the existing code that are pointing to our function.

If you find yourself copying and pasting code everywhere in your software project or your software gets to a point where you can’t change anything or changing one thing breaks many other things, that means your software has serious design flaw. The software that cannot easily be changed are called Rigid software. The word “soft” in software means that it should easily be changed, otherwise it just defeats the purpose. As “Uncle Bob” says, you just re-invented hardware.

This is where Design Patterns comes in to play. It teaches you the discipline of how to design your software architecture and how your architecture can easily evolve to change in requirement or adding new functionality. If you are a junior developer and want to advance to a senior role then Design Patterns is one of the things you must have in your toolbelt.

You have already seen design patterns in the frameworks you have used either Java, .Net or C. In .Net, the code below will be very familiar which gets a list of .txt files in a folder. Notice how we instantiate a DirectoryInfo object and then use .Getfiles() and it is imported from System.IO namespace. You keep reusing this code wherever you want to read a list of files, you don’t care how it is implemented, you just use it.

using System.IO;
string folder = “C:\”;
DirectoryInfo dir = new DirectoryInfo(folder);
FileInfo[] files = dir.GetFiles("*.txt");

There are 23 popular design patterns first introduced in this book by 4 authors called the Gang of Four.

Design Patterns - Elements of Reusable Object-Oriented Software

If you don’t have time constraints, read the book. But if you are like me and want fast results then video is the way to go. Below is the link to Design patterns video training by my favorite author. It comes in two parts, you can buy each part separately or together in a series.

The Ultimate Design Patterns: Part 1

The Ultimate Design Patterns: Part 2

The Ultimate Design Patterns Series


Questions, Comments below. Happy programming.



Author: Ahmad Faiq Ateel

By: Ahmad Faiq Ateel
Ahmad Faiq Ateel

Published: 1/27/2020