DEV Community

Cover image for Why you Should get Into Coding Patterns Right Away 🏁
Jessica Veit
Jessica Veit

Posted on • Updated on

Why you Should get Into Coding Patterns Right Away 🏁

First and for most - I would love to hear your thoughts on

When in ones developer journey should one look into the topic of patterns?

As of my opinion is as early as possible and here is why! 😊

Software development can be simply descripted as solving problems and occasionally drinking coffee ☕. Although this is what we as developers do and also what we hopefully enjoy doing, there is not always a need for that. You might ask why? Well, firstly that in your hand is properly not your first one of the day, and secondly lots of people, especially four very dedicated man, already did a lot of thinking for you 🧠.

Disclaimer
Do not get me wrong, finding your own way of problem solving and kind of developing a 64-bit sense for it is a crucial skill you need as a developer, yet I think especially for beginners it is not any less interesting as it is educational to see how other people approach all sorts of problems.

Where to Start

When talking about design patterns in software engineering the Gang of Four Design Patterns are what most people think of. Those are your goto for any sort of somehow generic problems like...

Factory Method: To create instances of different implementations of an interface.

Composite: To compose objects into tree structures and work with these structures like with individual objects.

Iterator: To iterate all elements of a collection without exposing their underlying representation.

Just to give a quick overview on those patterns, there 23 of them, categorized into:

  • Creational Patterns
  • Structural Patterns
  • Behavioural Patterns

In the book Design Patterns: Elements of Reusable Object-Oriented Software each pattern is descripted and exemplify with UML diagrams, template source code and a real-world example. It is very well-written and gets you right into the different topics and use cases.

How I Practiced Them

Back in school, my professor always did the following three-step-approach of showing us the purpose of a new pattern:

  1. Explain a problem
  2. Give time to the students to come up with their own solution
  3. Discuss the approaches and present the pattern-solution

I loved this technique of him teaching us as we were given the chance to think about a problem and understanding it as a whole. Additionally, since then I always had a distinct example for every pattern in my mind!

What to do Next

So, now that you got all your sources of information ready, maybe even a collection of code snippets and explanations, what next? Think through them, maybe find real-life examples based on your own experience and code, code, code as one of my professors always used to say:

I didn’t really understand it - until I tried it!

In the End

Design patterns are a great thing to know. They make the life of a developer much easier and are optimal against headaches and bad code design, yet bear in mind that these patterns should support you and you should not just blindly follow along.

Understand what code can do and what you can do with code!

Photo by Jonas Svidras on Pexels 🎉

Ps.: Also an amazing tip in terms of improving your coding skill and the overall quality of your code is the Clean Code Initiative providing the theoretical input and also a roadmap on how to go about it.

Top comments (4)

Collapse
 
nombrekeff profile image
Keff

Fantastic post, I like the disclaimer at the end, I've seen patterns used incorrectly a lot, and I've also used them wrong multiple times. Having a good understanding and experience with them is really important so I agree with your idea of starting as soon as possible

Collapse
 
jessica_veit profile image
Jessica Veit

Thank you very much for your feedback! Using patterns wrong is common and a good thing in most cases as it often shows that somebody wants to try something new 😄 Yet, if someone attempts to solve every problem with the same pattern or generally every problem with a pattern they are on the wrong train 🚂

Collapse
 
nombrekeff profile image
Keff

That's it, not evey problem can be solved using patterns!

Collapse
 
andrewbaisden profile image
Andrew Baisden

Grasping the concepts of patterns is key to progressing further as a developer.