Voting: Unterschied zwischen den Versionen

Aus Java Student User Group Austria - Java + JVM in Wien Österreich / Vienna Austria
Wechseln zu: Navigation, Suche
(jEggYVmBrrYHsvB)
(RhzqwzkLoLIwuXho)
Zeile 1: Zeile 1:
Hi, Cedric.IoC is a design/coding plihosophy that's seperate from the frameworks that implement them. I don't use the frameworks, so I can't talk about them.Typically, I hand code factories. I start by having the factory simply return a new instance, and over time I find I need to get the factory to configure the instance in some way. That's where IoC comes in. It works pretty well for me, and of course as the factories are hand coded, there's no refactoring problems.One point I would stress is that you really want to use interfaces when using IoC. This way, only the factory needs to know about the IoC hooks.Finally, both Eclipse and IntelliJ offer the option of searching non-Java files when renaming. I'd advise always previewing what it's doing when doing this though.
+
Perhaps it's just my limted penasrol experience with IoC, but I'm not convinced (yet) that making my classes more complex by adding calls to factories that abstract away calls to service locators (or worse, making my classes depend directly on the IoC containers themselves) is all that much better than a few extra parameters being passed into a constructor. Perhaps another valid approach would be to consider why the class has so many different contexts that not all of the dependencies are used in every case and refactor it down to multiple classes. In the end, I'm sure there are cases where both approached make sense  thanks for pointing out the design consideration!

Version vom 16. Dezember 2012, 06:50 Uhr

Perhaps it's just my limted penasrol experience with IoC, but I'm not convinced (yet) that making my classes more complex by adding calls to factories that abstract away calls to service locators (or worse, making my classes depend directly on the IoC containers themselves) is all that much better than a few extra parameters being passed into a constructor. Perhaps another valid approach would be to consider why the class has so many different contexts that not all of the dependencies are used in every case and refactor it down to multiple classes. In the end, I'm sure there are cases where both approached make sense thanks for pointing out the design consideration!