DEV Community

Discussion on: When is your code 'good enough'?

Collapse
 
itamarst profile image
Itamar Turner-Trauring • Edited

"Good code" or "Bad code" isn't a practical or useful way of thinking about it, because it's not just about the code, it's also about the situation and goals.

A better way of thinking of it is "fitness to purpose": does this code fulfill your goals?

  1. You might need to maintain the code, which requires one set of criteria...
  2. or you might run it once and throw it away.

Those two situations result into two different kinds of fitness to purpose, two different ways of judging your code.

Longer version: codewithoutrules.com/2017/11/07/no...

Collapse
 
ignoreintuition profile image
Brian Greig

I consider anything that is going to be maintained for any significant amount of time to require some degree of quality.

Collapse
 
itamarst profile image
Itamar Turner-Trauring

It's the other way around: "quality" has no meaning except in regard to your goals.

If maintaining something is a goal, then your code needs to meet certain properties, which you then call "quality". But "quality" is not a property of the code itself, separate from its goals: it only makes sense in a specific situation.

Thread Thread
 
ignoreintuition profile image
Brian Greig

Maybe I am a bit biased because my background is in enterprise software so code is maintained across dozens, if not hundreds, of developers and even small changes can persist for years. Having well-defined code quality standards that are shared across teams is imperative.

Thread Thread
 
itamarst profile image
Itamar Turner-Trauring

Right, and that's a specific situation with specific needs. Not saying you don't need those standards, just saying those standards are situational.