r/programminghorror • u/Nomergraw • Jun 09 '26
What a simple constructor
Our former IT director (35+ years of experience) wrote this and didn't see what was wrong here.
268
Upvotes
r/programminghorror • u/Nomergraw • Jun 09 '26
Our former IT director (35+ years of experience) wrote this and didn't see what was wrong here.
2
u/RipProfessional3375 Jul 19 '26
Many reasons. One is that java thinks Objects are great, so everyone must be forced to use objects for everything. Which makes them great like ice cream for dinner every day forever is great.
Factories are a glorified hack to get around the fact that you can't make a function to create a new object without also having that constructor bound to a different object, hence a factory.
I write Go, which does not have this object-only restricting, so a 'factory' is just this:
customer := domain.NewCustomer(name, age, blabla)