[Building Sakai] More on Covers - From Twitter

csev csev at umich.edu
Tue Mar 23 20:58:28 PDT 2010


The conversation about alternatives to covers continue on twitter and I could not respond to it all in 142 characters - so back to the dev list I go.

Lance asked if I liked Annotations better than XML and Setters.

Definitely yes - less syntax is better and avoiding XML is a big win in terms of documentation and training IMHO. My biggest connern is that is we need to somehow control the moment of constructor and let Spring do the construction - then I have a problem for things like portlets and jws files, and lots of other little gluey things.  Another concern is making sure that there was a moment where I could check that all was well rather than randomly having NPEs is startup did not work.

Steve Swinsberg said "you could use the ComponentManager which is Spring without the XML. Adds two extra lines per cover."

I think you meant to say - "it takes two more lines than cover" - but my answer is yes - I am fine with using Component Manager to get the impl - no need to get Spring involved in constructor time - no worries about startup order - a little extra code is not such a big deal.   I would particularly like to find a way to make this as contracted as possible - for example - I don't want a try / catch around every ComponentManager lookup - And I don't want it returning NULL when it can't find an impl - that looks like a NPE one line later - I want the CM lookup to immediately traceback out with a good descriptive error when there is a missing impl.  Also with a bit of work we might get the wordiness down a bit.   It would be nice if one could do all the lookups at init time or constructor time for simple stuff like say a Portlet or JWS.  

But after all that, aren't the static covers simply a way to call the component manager and use the returned instance?  Or is the key that you want to get the instance over and over so that unit tests can inject something different each time.  I just wonder if CM lookups solve the need to poke Mocks into pieces of code.  It would seem if CM lookups were mock-enabled that static covers would be too - or am I missing something?

/Chuck



More information about the sakai-dev mailing list