Timeline for Perplexed by dependency injection principle - what if it is runtime dependant which objects are created?
Current License: CC BY-SA 4.0
9 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Sep 14, 2018 at 2:15 | answer | added | Filip Milovanović | timeline score: 0 | |
| Sep 14, 2018 at 0:20 | comment | added | Robert Harvey | Some programming languages will allow you to instantiate a type directly using a string name, such as C# as shown here. | |
| Sep 13, 2018 at 23:23 | answer | added | candied_orange | timeline score: 1 | |
| Sep 13, 2018 at 20:55 | review | Close votes | |||
| Sep 18, 2018 at 3:00 | |||||
| Sep 13, 2018 at 20:42 | comment | added | Robert Harvey | In a switch statement. You return a custom object using return new whatever() in each case. It's a classic example of a Factory Method pattern. You don't actually need any local variables to make it work, unless of course you feel like holding onto the resulting IMove object locally. | |
| Sep 13, 2018 at 20:32 | comment | added | gaazkam | @RobertHarvey Because how can I decide what type it gets? | |
| Sep 13, 2018 at 20:31 | comment | added | Robert Harvey | Instead of creating 77 privates of specific types, why don't you just create one IMove private?. | |
| Sep 13, 2018 at 20:07 | answer | added | Andy | timeline score: 3 | |
| Sep 13, 2018 at 19:53 | history | asked | gaazkam | CC BY-SA 4.0 |