Heuristics, Self-Improvement, Self-Learning

Starting in an ongoing software project

Monday morning, 6 AM. You vault out of bed and into the shower, pick out your nicest outfit and leave for work. Finally, a new project. A breath of fresh air. The excitement of starting on a new team. The joys of digging into an unfamiliar codebase! 

In this post I provide some techniques I use to get a grasp on a new codebase fast. It’s always fun to start a new green-field project, but let’s be honest for a moment and acknowledge the fact that most projects you will work on as a software developer will start from an existing codebase. These tips and tricks will help you hit the ground running, even when you land in a muddy brown-field mess.

Continue reading

Standard
Heuristics, Self-Improvement, Self-Learning, Testing

Legacy code retreat

Have you ever worked with code that literally brought tears to your eyes? Not in the good sense, mind you. I’m talking about code that is such a hassle to work with it makes you rethink some of your career choices. If that’s the case, a legacy code retreat might be just what you need to stop your fear of legacy code and instead start to appreciate the opportunities for improvement it provides. Legacy code can be a joy to work with, if you tackle it the right way.

Continue reading

Standard
Heuristics

Who do You write code for?

TL;DR: You should write code in a way that your colleagues would understand best. After all, they are the ones that will be reading it over and over again. No matter in how much of a hurry you are, you should always take the time to give things meaningful names.

Who do you write code for? It’s a simple question with an obvious answer.

As Martin Fowler bluntly states it:

Any fool can write code that a computer can understand. Good programmers write code that humans can understand.

The days of a programmer writing cryptic assembly code that only their computer understands have long gone by.  The question deserves attention however, as I seem to keep bumping into examples that prove not everyone shares this belief (or is too lazy to act upon it).

The example

Recently, I came across a bit of SQL code that looked like this:

DECLARE @nvcWFN_SQL NVARCHAR(MAX)
DECLARE @nvcWFN_SQL_1 NVARCHAR(MAX)
DECLARE @nvcWFN_SQL_2 NVARCHAR(MAX)
DECLARE @nvcWFN_SQL_2Bis NVARCHAR(MAX)
DECLARE @nvcWFN_SQL_2Bis2 NVARCHAR(MAX)
DECLARE @nvcWFN_SQL_2Bis3 NVARCHAR(MAX)
DECLARE @nvcWFN_SQL_3 NVARCHAR(MAX)
DECLARE @nvcWFN_SQL_4 NVARCHAR(MAX)
DECLARE @nvcWFN_SQL_4Bis NVARCHAR(MAX)
DECLARE @nvcWFN_SQL_4Bis2 NVARCHAR(MAX)
DECLARE @nvcWFN_SQL_4Bis3 NVARCHAR(MAX)
DECLARE @nvcWFN_SQL_5 NVARCHAR(MAX)
DECLARE @nvcWFN_SQL_6 NVARCHAR(MAX)

--The code goes on by initializing these variables with parts of
--a SQL SELECT query

SET @nvcWFN_SQL =
        @nvcWFN_SQL_1 + @nvcWFN_SQL_2 + @nvcWFN_SQL_2Bis +
        @nvcWFN_SQL_2Bis2 + @nvcWFN_SQL_2Bis3 + @nvcWFN_SQL_3 +
        @nvcWFN_SQL_4 + @nvcWFN_SQL_4Bis + @nvcWFN_SQL_4Bis2 +
        @nvcWFN_SQL_4Bis3 + @nvcWFN_SQL_5 + @nvcWFN_SQL_6

--Execute the dynamically generated query
EXEC sp_executesql @nvcWFN_SQL

This is part of some code that generates a complex SQL query at runtime. Ignore the fact that this might not be the best idea ever, but just analyze the code itself.

Continue reading

Standard