Developing a pattern to your coding process

A lot of people will learn great things and become extremely good at those things. But a lot of those people, although they are very good at what they do, may not have a formal process that they are aware of. Or may not have discovered a pattern to that process.

I’ve recently been doing a lot of coding exercises on HackerRank. And I’ve discovered a simple process to development. Something I’ve always been doing but never thought much about. Sure, there are a lot of processes involved in software development. This includes TDD, integration testing, CI, CD, and so on. But there’s an even simpler one that I’ve been taking for granted.

A side note, HackerRank coding exercises are small and challenging. So the amount of code involved in the solution is not usually a lot. But finding an efficient solution without an overdone architecture is key.

When working through a challenge, I may iterate through a number of ideas. But often the one that works best has more variables than needed, all in an effort to see clearly. A simple line of code may be broken down into four or five lines, just so I know where things are coming from. But once the solution is complete, I’ll explore ways to simplify it. Now that I know the mechanics of the working solution, it becomes much simpler to digest.

Once the refactoring is done, the final part is clean-up. Remove any unnecessary output, unneeded comments, etc. Make sure the lines of code are grouped properly. And any variable assignments that are done once, used inline instead.

So what’s the point of all this? I remember being a junior developer rushing to get stuff done and leaving crap behind. Even senior developers do this. So to have a clear process makes it easy to step through the task.

So in short, here is the patterned process:

  1. Develop a working solution.
  2. Refactor into efficient code.
  3. Clean-up.

In real development, you can add unit testing to the first point. And use those same tests as an aid to the second point.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s