A good programmer is akin to a good writer: he or she knows the rules and thus knows when to break them. A bad programmer breaks those rules without knowing why and thus has no good reason for it.
In other words, good code is a very contextual things. As a result, good code itself is hard to define but for a start on some guidelines you can check out 'use strict' is not Perl. (though I confess that it's a bit dated and I should fix some minor booboos in it -- particularly the part about orthogonal code).
New address of my CGI Course.
Silence is Evil (feel free to copy and distribute widely - note copyright text)