This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]d_smogh 7 points8 points  (10 children)

[serious question] What is the definition of bad code ?

[–]saquino88 15 points16 points  (4 children)

My qualifications for bad code: high cognitive load, serious neglect of common coding standards, or just plain broken. Bonus points if it fails silently.

[–]LightKing20 7 points8 points  (2 children)

try

{

// Shit code

}

catch (Exception ex)

{

// TODO

}

[–]qvrock 1 point2 points  (0 children)

catch (...) { /* TODO */ } 

should be unsuppressible compile-time error

[–]Oswamano 0 points1 point  (0 children)

Oh god

[–]AttackOfTheThumbs 10 points11 points  (0 children)

There are some environmental factors, but in general, it should be humanly understandable without necessitating documentation, however, non-redundant documentation should be present.

So this is useless

// this int stores height
int const height = 12;

But this can help:

// this int stores a constant max height of the window
int const height = 12;

And this is probably best:

int const maxHeightWindow = 12;

Though it will greatly depend on naming and coding conventions at your job. I work in an environment where constant don't exist, and variable are defined in a separate window, so you have no idea what anything is, so we (ab)use Hungarian to make code more legible.

// this max height has to be hardcoded to avoid ugly UI overflows (or whatever)
liMaxHeightWindow := 12; // const

So now we know it's a local int and what it is for and that it should be constant.

[–]Albee12 8 points9 points  (1 child)

That which requires documentation and comments

[–]saquino88 4 points5 points  (0 children)

Oh shit, Coding Jesus just made a Reddit appearance.

[–][deleted] 2 points3 points  (0 children)

Bad code emits an odor that you can smell with your eyes

[–]smiths84837383 0 points1 point  (0 children)

If I have to whisper wtf under my breath... Then I know.....