[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: WiredMicrocontainerTest

adrian@jboss.org do-not-reply at jboss.com
Wed Mar 5 08:20:59 EST 2008


"alesj" wrote : "adrian at jboss.org" wrote : 
  |   | I already went through and fixed this once and combined three or four classes you'd created in the package back into the main test class. :-)
  |   | There's a previous thread about it somewhere?
  |   | 
  | You call it 'N<->M problem', I call it OO approach. :-)
  | 

No. If it is OO you ask the question, isA (inheritance) or hasA (encapsulation)

In this case it isn't very clear, you can make arguments for either.

My test isA wired test
My test hasA wired controller registration

In general, if it is not clear, use hasA because it avoid the N<->M problem
(absent multiple inheritance :-) and enables greater reuse.

NOTE: Many people would argue that setters are not a correct use of encapsulation
(I just call it externalising the policy ;-). 

But you can just make it a protected setter if you think it really breaks encapsulation
and you want policy controlled by subclasses (that ways its really no different from
constructor parameters except you don't have to create 5,000 constructors 
for all the different policy parameters and their permutations. :-)

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4134240#4134240

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4134240



More information about the jboss-dev-forums mailing list