Wednesday, September 30, 2009

Code

So, writing great code is an art.  It is a talent.  It is something that I'm not sure can be taught, perhaps learned, but I doubt taught.  Writing good code, though, can be taught.

To me, quality code can be graded via the following, not necessarily in any particular order of value:
    Readability
    Reusability
    Maintainability
   
For readability, everyone has their own flavor.  However, find your standard, and stick to it.  Nothing upsets me more than seeing a function that can't even figure matching brace behaviors:
function blah() {
    for (...)
    {
   
    }
}

It reads like an awful, awful book.  Other than picking a standard and sticking to it, defining the "right" way and "pretty" code is completely out of the control of one person.  It would be extremely cocky and stupid to think that I know the "one" way to right clean code.  I'm still under the assumption that my code has a long way to go to meet even my own expectations, let alone those of others.

As for making code reusable, I think the most important thing is being able to draw the functional lines.  Know where the data library ends and the control library ends.  Study design patterns, the gang of four knew their stuff.  Know and understand MVC (model view controller).  Turn everything you can with an end product into a library.  Sure, there are limits, but find them and understand them.

Maintainable code?  That's really covered by the previous two.

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home