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
-
D--M22686yMy small gripe: get rid of the if else and rethink if your function needs should return something when you do:
CreateCustomer(); -
Pretty sure that's not how factories work. It has to work like a literal factory, where you send in X raw material inputs, process them and always spit out a similar output for each particular input. Like a car factory would do. Take in parts and spit out a car.
If it has side effects, or non exclusive dependencies, it isn't a factory. If it's not dealing with one particular type of processing, with known inputs and outputs, it isn't a factory. You can't build flashlights in a car factory. -
@hashedram I understand now, I'll rewrite my code making in hope I get it right this time
-
@gitpush if you don't *need* factories then don't use them. Really you'll know when you need them. Ex) you have all these specialized versions of a user where there are only slight difference in the way you have to create them, but you don't want to implement the same function over and over to create them with only minor modifications. If you can encapsulate that creation behavior, then that is when you could use a factory.
Related Rants
Did I screw up or is it ok doing this?
1. Calling another method inside the same factory file
2. Calling a method from another factory file
3. All factory methods are static because they only depend on their passed parameter(s)
question
hope not
did i screw up?
typescript