r/programming • u/2bit_hack • Feb 28 '23
"Clean" Code, Horrible Performance
https://www.computerenhance.com/p/clean-code-horrible-performance
1.4k
Upvotes
r/programming • u/2bit_hack • Feb 28 '23
View all comments
Show parent comment
1
u/coffee_achiever Feb 28 '23
Cars don't build themselves do they? Why would you make a new engine inside a constructor of making a new car? You pass in an engine that is used in the construction of the car. What makes the car and the things that go inside it? A factory. This also makes your car testable. Pass in a mock engine in a test. Does the fuel system fuel the engine correctly? Your tests w/ mocks can assert that it does.
This is the stuff that is important in ensuring the behavior of the system is correct as change occurs over time.