Don't use IoC if you don't need it, but I'll explain why we need it in our case: some customers require different implementations. That's where the DI part comes from -- to enable us to load a different dependency based on the customer. Now, you could provide a different bootstrapper class per customer or start building a mega class with a lot of ifs-and-buts(elses), or you specify this kind of stuff in a configurati…
Why not just split out the shared code into libraries and make your main() be different for each customer?
The inverse of IoC is Control
21–30 of 66 posts
Re: The inverse of IoC is Control
#22Don't use IoC if you don't need it, but I'll explain why we need it in our case: some customers require different implementations. That's where the DI part comes from -- to enable us to load a different dependency based on the customer. Now, you could provide a different bootstrapper class per customer or start building a mega class with a lot of ifs-and-buts(elses), or you specify this kind of stuff in a configurati…
I agree with using IoC for different implementations, but I'm puzzled by those who want to use it everywhere, because it supposedly makes the code easier to test. Guice is a nice IoC framework, but look at what they say on their website: "Think of Guice's @Inject as the new new." http://code.google.com/p/google-guice/
Re: The inverse of IoC is Control
#23There are many programmers working in the Real-World [TM], powering great apps and webapps, using saner technologies who have never heard of the term.
I wrote my own IoC container (a clone of picocontainer IIRC) to see what the fuss was about when the term started to become fashionable. No big deal. It can help reproduce various states (for examples in testing environments) to more easily test your app.
Sure people will say: "You need an IoC container to do DI, what you're talking about is DI, not IoC".
But, fundamentally, it is once again related to "state" and the difficulty to recreate a state in {dev,pre-prod,prod,whatever}.
So it's once again a "solution" missing the bigger picture.
Sure, people stuck in the "stateful OO" mindset will love IoC and, honestly, if you're stuck in such an hell IoC can be useful. With the caveat that IoC makes it much harder to reason about what's going on when some shit hits the fan.
"Every problem can be solved with another layer of abstraction, except the problem of too many layers of abstraction"
But there's light at the end of the tunnel. There are other ways to design great apps.
And to make you feel even better: being "smart" as nothing to do with knowing every technology out there ; )
Re: The inverse of IoC is Control
#24This problem will typically surface whenever you add a dependency between existing components. If the dependency is currently instantiated after the changed component, it will have to be moved up so it is instantiated earlier. But then it turns out the dependencies of that component also need to be moved up etc.
To deal with this you then have to calculate a "dependency rank" for each component (i.e. 0 for components without dependencies, and x+1 for components where the max rank among the dependencies is x) just to figure out a new order that works.
This problem doesn't exist if you use a dependency injection container with configuration in code, because the order of component registration is not important.
Re: The inverse of IoC is Control
#25Re: The inverse of IoC is Control
#26Re: The inverse of IoC is Control
#27Earlier quoted context omitted.
Just curious, but what's wrong with recompiling? If you make a typo in your Rhino file on production, your whole app is now failing. Surely it makes more sense to just take the 5 minutes to recompile (or hopefully 30 minutes and test it out in dev first)? I don't really understand what problem using the dynamic language is trying to solve there, and you've just added in a whole new branch of different code that won't…
In my case, I have an Eclipse-based product (toolchain for embedded development) that must be reconfigured per client or even per project (on site); i.e. it is more about dynamically creating very specific variants of a product. Using client/project-specific plugins would be the alternative for me, but this has much more overhead.
Seems better to make an automated build system off a database of configurations - a simple sql table with the different settings that could automatically build versions for all clients. You'd get static compile time checking of each build, and it would allow for easily running automated tests against each client's version.
So you'd end up with no un-used code, a database of client configuations, and static compile time checking. Seems win-win.
Sorry for 'assuming your problems', feel free to ignore. Interesting situation though.
Re: The inverse of IoC is Control
#28Re: The inverse of IoC is Control
#29Maybe you should be using C#. As a community we fight hard to reject xml configuration, favoring type safe lambda expressions instead. Anything that ignores the type safe guarantees that C# offers quickly does. There was briefly a spring.net but it quickly died for this reason.
IoC containers in C# have rejected config in XML, in favour of config in code, using either generics and lambdas (e.g. register Component.For.ImplementedBy ) or via scanning (e.g. AllTypes.FromAssembly(x).BasedOn().WithService.FirstInterface() ).
Spring.net was an exception and in comparison it really sucked.
IoC Config in code is much better. But can't this be done in java too?
Re: The inverse of IoC is Control
#30Java culture (IDE-dependence, AbstractFactoryVisitorFactory patterns, Maven and XML monstrosities) is hideous. It's based on the idea that reading code is a lost cause. You can no longer trust code, so you need all these wonky tool configurations to compensate for the fact that you're trying to make an army of inept programmers build something that is (unless it fails) going to become the next generation's legacy blo…