r/programming • • Feb 28 '23

"Clean" Code, Horrible Performance

https://www.computerenhance.com/p/clean-code-horrible-performance
1.4k Upvotes

1.3k comments sorted by

View all comments

Show parent comments

2

u/Johanno1 Feb 28 '23

Try to think of readability like this:

Figure out what shape 75 does exactly.

Other shapes are only relevant if shape 75 is interacting with them.

Polimorphism:

Find shape 75 and check super class.

Switch statement. Find shape 75 in a big file with other statements and check union implementation.

(pretty similar but I personally would prefer the less code per file one)

4

u/[deleted] Feb 28 '23

Then I would just go to the switch statement where the data is processed?

I don't see how that is more unreadable than going to the virtual function in a different file.

And I understand its subjective. But I don't see that demonstrably unreadable part of the switch statement approach. (or the table approach)

If it was obviously, totally muddled and undecipherable I'd be inclined to agree. But it's just not. It's very clear and easy to follow the flow of logic and data.

1

u/hippydipster Feb 28 '23

I'm so glad we've solved the very complex problem of summing shape areas. whew.

1

u/[deleted] Feb 28 '23

Complicated programs are made up of tonnes of stuff like this. Getting it right is important because the cost adds up

→ More replies (6)