Think about patterns and express code in the best possible way

Chris Cooney
Jul 4 · 2 min read
Photo by Jon Asato on Unsplash

Whether you’re writing code, managing other engineers or drawing up architecture diagrams, there is one question that should be at the absolute forefront of your thinking.

It should shape every technical decision you make. For an engineer, it is consideration number one.

“Am I setting a good pattern here?”

Is this a good pattern? What if someone else did this thirty times? The universality of your code is a fundamental principle that helps to safeguard software quality.

Let’s look at an example. Consider the following class.

You’re tired and you need to add another name into this, so what do you do? You pull out the old CTRL+ A, CTRL+ C, CTRL+ V.

But what happens when we universalize this code? Are you setting a good pattern? Let’s fast forward.

So, when we look into the future, we see a mess.

It’s not enough to assume that “someone will come along and fix it”. They won’t. You have to assume business pressure is constantly high. You need to be the change you want to see in the code.

What if you thought about the pattern upfront and did something like this?

It’s not perfect, it’s not infallible, but it’s a step in the right direction. The pattern is sound. It might need refining in the future, but for now, you’re making sure that a mess isn’t made with the frameworks you set.

Patterns Are the Lifeblood of Good Code

When you establish clear patterns for performing a task, engineers don’t need to worry as much.

You create a library of knowledge that’s passed on through the code. If your business is looking to learn how to make engineering move faster, tell them this.

If you’re struggling to handle drift in the code, get thinking about patterns.

Be brave and tackle problems as you see them. Wrangle them down to size and express the code in the best possible way.

I’m rambling about tech all the time on twitter

Better Programming

Advice for programmers.

Chris Cooney

Written by

Software Engineer.

Better Programming

Advice for programmers.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade