Design Patterns

04 Dec 2024

Have you been using design patterns?

If you have never heard of design patterns than your first reaction might very well be to say no. That was my first reaction because when I heard those words I thought they meant some sort of preset outline for writing code and I don’t follow any outlines when writing code. But design patterns are really just concepts for how you structure your code. For example a Singleton pattern refers to classes that can be instantiated once and then globally accessed throughout an entire application. Reading that I bet a great many coders would say that they have done that at least once in their coding experience. I know for certain that I have done it on numerous occasions.

Why should you care?

Thats a good question. You could memorize a bunch of design patterns and then go about coding by saying hey I want to code something using blah blah blah pattern so I am going to format everything to follow that. If you do that your an idiot. All that is doing is restricting your code. It does not help you in any meanigful way. On the other hand say that you have a project and it needs A, B and C you could go hey A needs to do blah and the structure of this design pattern should work well. In this you have a goal and you are using a design pattern to help you plan out your achievment of that goal. This is where design patterns can be helpful. They can help you create an outline for how you want something to work but should never be used as a road to completion, more like an arrow pointing in a direction.