Timeline for Why should I use a factory class instead of direct object construction?
Current License: CC BY-SA 3.0
8 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Dec 9, 2017 at 1:58 | comment | added | Breno Salgado | Constructors rule | |
| Sep 26, 2017 at 14:07 | comment | added | soufrk | But this argument can be held valid true for Builder Pattern as well. Isn't it ? | |
| Apr 12, 2017 at 7:31 | history | edited | CommunityBot | replaced http://programmers.stackexchange.com/ with https://softwareengineering.stackexchange.com/ | |
| Mar 17, 2017 at 18:15 | comment | added | TheCatWhisperer | This is the only satisfying answer I've seen here, saved me from having to write my own. The other answers are only dealing in abstract concepts. | |
| Aug 14, 2014 at 15:07 | comment | added | KaptajnKold | +1 I find that adhering to a rule of absolutely no logic in a constructor is not a bad idea. A constructor should only be used for setting the initial state of the object by assigning its arguments values to instance variables. If anything more complicated is needed, at the very least make a factory (class) method to build the instance. | |
| Aug 14, 2014 at 13:13 | comment | added | DougM | The choices are not only "factory" or "constructor." A Feeder might use neither, and instead call it's Kennel object's getHungryAnimal method. | |
| Aug 14, 2014 at 6:45 | vote | accept | rufanov | ||
| Aug 14, 2014 at 6:45 | |||||
| Aug 14, 2014 at 3:40 | history | answered | Arseni Mourzenko | CC BY-SA 3.0 |