Linked by Thom Holwerda on Fri 15th Feb 2013 10:40 UTC
General Development "Since I left my job at Amazon I have spent a lot of time reading great source code. Having exhausted the insanely good idSoftware pool, the next thing to read was one of the greatest game of all time: Duke Nukem 3D and the engine powering it named 'Build'. It turned out to be a difficult experience: The engine delivered great value and ranked high in terms of speed, stability and memory consumption but my enthousiasm met a source code controversial in terms of organization, best practices and comments/documentation. This reading session taught me a lot about code legacy and what helps a software live long." Hail to the king, baby.
Permalink for comment 552884
To read all comments associated with this story, please click here.
RE[7]: Comment by ilovebeer
by Alfman on Tue 19th Feb 2013 06:05 UTC in reply to "RE[6]: Comment by ilovebeer"
Alfman
Member since:
2011-01-28

ilovebeer,

"I am saying code quality is not black & white and you agree that the judgment of code is often a matter of opinion, yet you insist code is either good or bad. You can't have it both ways, either there is grey or it is black & white only."

Who said it's black and white? It's full of greys. You should visualize it as a multidimensional venn diagram that often contains many good solutions (as well as some that are on the fence or just plain bad). There's always a certain degree of subjectivity, but you are trying to extend this subjectivity well beyond what is reasonable in order to rationalize bad code.



"I never said engineering doesn't matter at all. I said if the software works as intended and is stable, it has been engineered correctly thus implying the engineering does in fact matter."

"...Remember, I said if it works, it works and there's no getting around it.. I did not say if it work but has problems, it works."


It's a fallacy to treat all code as being identical in quality even though it works. Here's a trivial example using a multiplication function, but imagine that it's thousands of lines of complex production code instead.

int A(int a, int b) {
return a*b;
}

int B(int a, int b) {
int r=0;
for(;a>0;a--) r+=b;
for(;a<0;a++) r-=b;
return r;
}

int C(int a, int b) {
if (a==0) return 0;
if (a<0) return -C(-a,b);
int* m=malloc(a*sizeof(int));
for(int i=0; i<a; i++) m[i] = b;
for(int i=0; i<a-1; i++) m[i+1] += m[i];
return m[a-1];
}

etc...

Hopefully this convinces you that just because something happens to work, it doesn't make it good code. Common attributes of bad code are lack of clarity, unnecessary complexity, insane difficulty to maintain, latent bugs which might not show up for years, etc. When good developers are faced with bad code, we're often tempted to rewrite the whole damn thing, but nature of our jobs sometimes means we have to 'fix' the bad code instead. This will technically work, but it still remains bad code. Fixing the memory leak in function C obviously won't make it good code.

Reply Parent Score: 2