Skip to main content
6 events
when toggle format what by license comment
Feb 26, 2019 at 3:40 comment added candied_orange @EtienneCharland new has to exist somewhere. But anything that contains new Foo() KNOWS that Foo is an implementation and not an abstraction. Spread that knowledge around and it becomes very hard to turn Foo into an abstraction later when you need to. Keep only a few things, like main() and factories, knowing which one Foo really is and you don't have to touch anything else when you do change it. This is the same issue if you switch to a keyword interface or an abstract class. In fact, the only difference is only one choice supports multiple inheritance. But using code shouldn't care.
Feb 20, 2019 at 3:17 history edited VoiceOfUnreason CC BY-SA 4.0
added 2042 characters in body
Feb 20, 2019 at 2:52 comment added Etienne Charland +1 for "If a particular component is already isolated from shared mutable state, and doesn't include slow code, the argument for not just using it in your test becomes a lot weaker." Had to read that a few times to get it. So if I close the external interaction boundaries with mocks, series of classes can work together without risk. Should I use Dependency Injection between those classes? In some cases it's good to do Dependency Inversion (APIs between modules) but in most cases simple Injection is all that's needed unless I'm mistaken?
Feb 20, 2019 at 2:31 comment added Etienne Charland Also, I saw several people say you should never use the "new" keyword in the code -- but don't specify whether that applies for classes like DateTime, TimeSpan or StringBuilder. Then on the other side are people saying extracting interfaces isn't always necessary, but then using those classes means I'll be using "new" in the code to create it. Or in those cases, do they still use the IOC to create the class instances and inject it even if not using interface? Using Dependency Injection without interface feels weird to me, it doesn't remove any coupling at all.
Feb 19, 2019 at 17:08 history edited VoiceOfUnreason CC BY-SA 4.0
added 232 characters in body
Feb 19, 2019 at 16:59 history answered VoiceOfUnreason CC BY-SA 4.0