An alternative to ColdSpring for dependency injection ?

Submitted by Falken on

I just came across LightWire, anything that stops people sticking createObject() all over the shop helps maintainability, but I always though ColdSpring was light enough - certainly compared to the amount of time Reactor takes to start up the first time.

I don't see a 'killer' feature, and if you are going to do DI to stop your code degenerating into a mess of Italian food, why not go with a more capable framework to start with ?

Of course, having just the one file could be handy, and it looks like it might be more able to cope with people who can't have mappings set up. Having the XML configuration file use the same syntax as ColdSpring also means that you can 'trade up' at a future point, if you watch how you use it.

One to keep an eye on.

Sections

Submitted by PeterBell (not verified) on Wed, 02/07/2007 - 19:25

Permalink

Three reasons to consider LightWire: (i) It is a single file you need to package with your project. Lets say you're doing a demo with an index.cfm and three cfc's. It seems to me a pain to have to (a) rewrite your cfcs to use application scope or (b) include the entire ColdSpring framework just to show someone a three file sample. (ii) You DI into transients. If you want to do something in the style of active record where User.cfc (a transient business object) needs access to a singleton like UserDAO.cfc, that is NOT recommended in ColdSpring (just ask Chris Scott). CS can do this but the overhead in the way it works is such that it isn't recommended for injecting into transients. This is fine as Dave and Chris use a service method approach rather than injecting into transients and the difference is basically just semantic, but if you want to inject into transients, you are going to want to consider LW. (iii) You want programmatic config. Dave Ross wrote an interesting article suggesting that people probably wouldn't use programmatic config even if he added it, but in the Spring world (ColdSpring is a CF port of the Java Spring ramework) there has been a debate raging for ever about programmatic configs and it is something Spring now supports (or plans to - believe it is in 2.0). If you only have 50 objects, XML config is probably ideal. As you have hundreds of business objects and say all of them have a service depending on a DAO, to programmatically configure that allows you to keep your config files much shorter. It is very early stage, but just post comment on my blog if any questions/problems. XML config not in yet, but should be this weekend.