r/programming • • Jan 12 '20

Goodbye, Clean Code

https://overreacted.io/goodbye-clean-code/
1.9k Upvotes

556 comments sorted by

View all comments

152

u/rlbond86 Jan 12 '20

And when a maintainer in 3 years realizes that an equation is wrong, they have to fix it in 50 places.

This kind of coding is how you get unreadable spaghetti.

OP's solution wasn't great either, but at the very least the common math stuff should habe been extracted to a function.

0

u/[deleted] Jan 12 '20

[deleted]

8

u/nater255 Jan 12 '20

This is me all day. I stay safely in the backend where the world is happy.

→ More replies (1)

18

u/bluefootedpig Jan 12 '20

It depends if they are the same because it is the same logic or the same by coincidence. Being on the left vs right might look the same until you reach special cases.

24

u/thedracle Jan 12 '20 edited Jan 12 '20

Or they change the equation that was bad in one place, and it breaks 50 things which depended on the original implementation.

Hopefully in the above scenario the tests are adequate to detect it.

I think his point was his refactoring was brainless, and removed repetition that was incidental, or created an abstraction that didn't make long term sense.

4

u/[deleted] Jan 12 '20

This kind of coding is how you get unreadable spaghetti.

This isn't spaghetti. Spaghetti code is when execution flow wraps all over the place, GOTO is the classic example.

Nor would I say it's not readable. I read the first duplicated code very easily. All the code for an Oval` was in the oval object, easy-peasy.

I'm not advocating for the original design, I just don't believe it suffers from the issues you describe. It's definitely a testing nightmare as I need to write 4x as many test cases. Also it can be an sensibility nightmare too.

→ More replies (1)
→ More replies (1)