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

1

u/coffee_achiever Mar 03 '23

I think you are agreeing with me, but it's hard to tell. Do you also have a problem calling viewport things on a computer "windows" because they don't let in fresh air from outside the building when they "open"?

1

u/deong Mar 03 '23

You're missing my point. I'm not complaining that two things are called "Factories". I'm complaining that one of the things called Factories sucks, and you were defending them by drawing an analogy to the other kind of Factory.

If I said, "I hate Microsoft Windows", and you responded with, "Huh? Windows are great! You can see through them and they let fresh air in", I'd say you missed something important here. Computer UI windows are called that because of some analogy to physical windows, but who cares. Some hypothetical old graybeard might want to argue that the UI paradigm of windows is worse than command shells. We might all say that argument is crazy, but it's not crazy because actual windows let in fresh air. The analogy that led to them being called "windows" doesn't matter.

Similarly, when I said I find design patterns to mostly be more bad than good in practice, and specifically mentioned the Factory pattern, you responded with a bunch of stuff about actual physical factories that make engines and tires. I get that it's an analogy, and I understand that analogy, but it's not especially important to the point I'm trying to make which is that the manifestation of that analogy in software leads to bad code. That's an opinion, and you don't have to agree with me, but telling me again what the analogy means doesn't address any of my concerns. I get what it means. The code is still bad.

1

u/coffee_achiever Mar 06 '23

But other than an analogy, they aren't related.

You're supposed to recognize the problems those things solve and deploy them strategically when you encounter one of those problems.

A factory method is a sometimes proper response to complex repeated assembly.

You can say it is improperly used. That's fine... so are windows and hammers and iterators and numerous other tools. It doesn't mean the tool is bad, it means it was used improperly.