On Wed, Feb 16, 2011 at 7:33 PM, Fabrizio Giudici <fabrizio.giud...@tidalwave.it> wrote: > I don't see how this solves my example. You're injecting prop in the > constructor of A. In my example, prop is computed also by B. This means that > the caller of the constructor of A must know how to compute B. It's not what > I want to do...
Just to make sure, what you are describing is effectively: public class A { private B b; private Function<B, Object> o; public B getB() { return b; } public Object getO() { return o.apply(b); } } To my knowledge, there is no way to do this where you can get to the application of o without it being a method call the programmer makes. I believe this is the "uniform access principle." (Or, more accurately, Java's lack thereof.) This is also why I typically don't care for using the members approach. As soon as you go from a simple member access to a computed value, it changes everything that was using that type. -- You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to javaposse@googlegroups.com. To unsubscribe from this group, send email to javaposse+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.