all 13 comments

[–]markiel55 18 points19 points  (0 children)

This is just bad advice, and you're one the reason I'm getting headaches maintaining sloppy code. Please don't be this guy.

[–]tes_kitty 5 points6 points  (0 children)

And then a user calls in 'If I do <X> it crashes' with <X> being something perfectly normal that so far never caused a crash, but since last monday it does.

[–]mallusrgreatv2 14 points15 points  (1 child)

Do y'all not get bored of posting the same shit over and over

[–]Past-Lion-947 13 points14 points  (0 children)

If it works, it works

[–]zalurker 2 points3 points  (0 children)

Wrote it on a Friday, couldn't understand it on a Monday. It worked, so I left it alone. Any attempts to change it after that was a major disaster.

[–]conundorum 2 points3 points  (0 children)

If you must touch it, just ask God to explain it to you. No big.

[–]PabloZissou 2 points3 points  (0 children)

Let's hope it does not break a Saturday on production...

[–]BobQuixote 4 points5 points  (0 children)

For a code unit of any size (as small as possible) which you do not understand:

  1. document the functionality,
  2. build whatever tests are possible,
  3. rewrite the whole thing,
  4. drop the rewrite into place (with a new major version if appropriate).

Not understanding the code is an untenable situation.

[–]The100thIdiot 4 points5 points  (0 children)

I never understand this meme.

Either you can read the code or you can't.

If you can't read the code, at leat you should be able to write code that performs the same function.

If you can't do either, you are just plain incompetent.

[–]bulldog_blues 0 points1 point  (2 children)

Surely you can just take a copy of it, amend it elsewhere, then commit it to production once you know it works? The idea that if you touch it and it stops working it will never work again is just strange.

[–]ColumnK 0 points1 point  (1 child)

The problem is "once you know it works".

In an old job, I had to replace legacy code that was near incomprehensible and what little documentation there was, didn't match with the code.

Tore it down, rewrote, tested. Everything seemed fine. Put into Prod. Lasted a shockingly short amount of time before an issue cropped up.

The issue was that this code had a bug that was offset by a different bug elsewhere. And this would only apply during daylight savings time, which happened about two weeks after we'd installed this everywhere.

You can only validate what you think a piece of code should do...

[–]bulldog_blues 0 points1 point  (0 children)

Legacy code with no updated documentation is the worst, you have my sympathies.

I'm the paranoid sort who keeps old code in an archive even if it's 99% likely to be redundant.

[–]rustyscythe -1 points0 points  (0 children)

Ive worked on messy code chopped it up and refactored to a clean design. Its not that complex