Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
fjmurau4875y@netikras The factory pattern has a point, but only if you're creating either more than one thing or a thing complicated to create.
But this is just pointless and ugly indirection. -
@fjmurau Not quite. Factory pattern also enables you to do some prep work. For instance if you use a constructor with new and later on you decide you need to extend how the object is constructed (or how it's constructed depending on the environment) you will have to either bloat your constructor with unneccessary logics or replace each and every call to that constructor with a factory method call.
If a component has a potential to become more complex or is complex already, or is likely to change a bit, or you are considering making a singleton, factory pattern does make sense. -
fjmurau4875y@netikras You wrote "prep work", I wrote "complicated to create", we probably mean the same. Stop nitpicking, this is DevRant, not StackOverflow.
My point: This factory was pointless! Agree? -
fjmurau4875y@netikras This implementation is indirection with absolutely zero abstraction. I wonder what the domain would have to look like to justify this.
But most of the clutter is uncommented code, and a public constant that is used nowhere in the project. -
@fjmurau I see 1 abstraction, 1 indirection, 1 maintainability point [created by the indirection] and an ability to make non-breaking backwards-compatible upgrades.
-
@netikras optional object post and pre-processing should never be done wrapped in a completely new object though; it either needs to be a subclass with more constructors (which means then you're creating a new subclass per function), or you should be using class methods to update your object.
Unless I'm not understanding what you mean by "factory pattern". -
Pickman6525yGuys.. Factory pattern?
This is 5 lines of code we are watching. For that the only pattern is KISS. -
Hazarth95215y@Pickman exactly this
The whole class can be replaced with
new CreateSendNotifier("any tag srsly");
For now, could be a case of pre-optimizing tbh
Related Rants
I hate it when (Java) programmers produce such clutter just because their OOP 101 professor told them to do so in 2005.
I refactored it using `git rm`.
joke/meme
java
factory