Who do you code for?

You are a writer. You read me correctly.  A writer.  Check it out.

writer

See?  Told ya.

As developers, we write code (text) for others to enjoy, either through the usage of the output it creates or … wait there is another thing to consider here?  … yeah .. or for others to read and learn from.

So when you’re writing code, who do you code for?

I code for “me” first when I’m stuck on a design/approach.  However, I would suggest not stopping there (and all kidding aside, I strive to push passed this point too).

Today I want to encourage you to think about the developers who might maintain the code later or even just read it in passing.  Let me show ya.  Now I’m using an extremely simple example to illustrate a larger point.  So hang with me.

Consider the following code:

var t;
foreach (int p in i) {
    t += p;
}
return t;

You can noodle out what this does right?  You CAN read it I’m sure.  You can likely explain the logic.

Read it out loud though.  Read it to a human.  Go ahead, try it.  Is that the way you talk to people normally?  Is it the way you’d write to them?

Now, how about this?

var total;
foreach (int price in items) {
    total += price;
}
return total;

Is that easier to read, as a human?  Is it closer to how you’d speak to another person?  Is the intent of the original developer more or less clear than in our first example?

Remember for variable names like this, the computer doesn’t care.  But we don’t write code for computers.  Sure we have to get the syntax right for the compiler.  However, we actually write code for PEOPLE.

So since you’re a writer, write code for people.  It just makes you a better author and a better human.

Did you enjoy this article?
Signup today and receive free updates straight in your inbox. We will never share or sell your email address.
I agree to have my personal information transfered to MailChimp ( more information )
Powered by Optin Forms