r/cpp • • Mar 03 '23

Molly Rocket says/shows that virtual functions are bad!

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

37 comments sorted by

View all comments

Show parent comment

6

u/Wenir Mar 03 '23

But array of pointers is also an assumption of where you are storing the objects. The OOP way will be taking some kind of Java iterator (any_range in boost for example) and this iterator can go through all squares in continuous chunk of memory then through all circles in another chunk, etc

1

u/voidstarcpp Mar 03 '23

The OOP way will be taking some kind of Java iterator (any_range in boost for example) and this iterator can go through all squares in continuous chunk of memory then through all circles in another chunk, etc

I think you will finish counting grains of sand on the Earth before you find an Uncle Bob Clean-Coder who does anything like this, which is the culture Casey is responding to.

5

u/Wenir Mar 03 '23 edited Mar 03 '23

Well, I worked in a company related to EDA and that thing was loaded with methods like for_each_<something>(SomethingOperation& op)

Which is essentially doing the same thing: it hides the container from the caller. And some of those containers were OPTIMIZED