What Makes Good Code?

As I continue to pour through WordPress themes in developing my own, I find it interesting to see how people tackle challenges. Even though we are all using the same languages to develop the themes, there are a million different ways that people come to the same answer.

This then brings up coding practices, and how one method of coding is better than another.

Most people seem to have developed almost a fingerprint in the way that they code, and even if it isn’t the best for optimization and the lightest on the server, they’ll still stand by their code because their method allows them to produce massive amounts of usable code that might take a perfectionist in optimization upwards of ten times longer.

Of course there are various standards, speed tests, and other information out there on writing the perfect code, but is it better to focus on producing shippable code fast rather than perfect code slow?

Even without taking personal coding speeds into consideration, coders seem split on how to do simple things in WordPress themes, like are you the type that echo’s out HTML or do you exit PHP before doing HTML? .

For as long as there have been coding languages, there have been various practices. In my experiences with Code Igniter, I found it hard to break from the way I coded things before and work within the constraints of the model, view, controller way of developing applications.

It seems like once you’ve learned how to code, changing can be as difficult as breaking deep set habits.

But coders have to remember that things change, new ways of doing things are found, and as developers we have to evolve, change, and adapt to the language we program in, making sure to create the best code we can for ourselves, our clients, and our companies.

So my original question still exists. What makes good code? Is it keeping up with the standards of the language? Is it fulfilling the needs of the client? Or is it something else?

How do you make sure that you write good code? Do applications keep you in check, other coders, or are you always reading the latest web development books and websites? Let me know in the comments below.

  1. By Phil Palmieri posted on March 6, 2009 at 2:58 am
    Want an avatar? Get a gravatar! • You can link to this comment

    My answer is that good code is a balance of standards, security and speed of deployment.

    When looking at it from the purist end, it should be the least amount of lines you can write to get the job done in the most secure way – with comments of course.

    From the business point, good code is standardized, well documents, tested, secure and easily picked up by new developers. – not necessarily the most creative, but the most reliable.


  2. By Paul posted on March 6, 2009 at 5:44 am
    Want an avatar? Get a gravatar! • You can link to this comment

    My answer is that good code is something that is readable and also the answer of Phil too 😀

  3. By Marty Thornley posted on March 6, 2009 at 7:55 am
    Want an avatar? Get a gravatar! • You can link to this comment

    I have to echo Phil’s comments.

    To add to that and answer one of the questions in the article, I definitely prefer to enter and exit php when I need it and go back to html, rather than echo html whenever possible. In a mostly html page at least. When I edit something like functions.php in WordPress, I keep it all php. Seems to make more sense there and functions.php is so quirky it causes less problems.

    I think the separation makes it a lot easier to read. I can quickly scan a page and see my layout and easily tell the php statements at a glance, especially in a color-coded html editor.

  4. Trackback