[cap-talk] Object capabilities versus dependency injection.
John Carlson
john.carlson3 at sbcglobal.net
Thu Nov 20 22:51:01 CST 2008
A lot of dependency injection in Java is done with Spring Framework/
XML or annotations.
The idea is to declare an interface, and then provide an
implementation at runtime, instead
of hard-coding in the implementation.
I think the thing that will make your code better is to write the
tests first...then people will use dependency injection more often.
However, Java testing frameworks have become more sophisticated over
time, so for example, I can set up my dependency injection in Spring,
and provide a test XML file for test code. The setup for spring is
done in advance of the tests in the test setup.
I would say that ocap discipline and dependency injection discipline
are very similar. Perhaps static methods should be deprecated, except
for factories. You can also pass Importers to your constructors.
This might be thought of as a small factory used to set internal state
of an object. This allows you to get rid of the setters and getters
on the classes which you are trying to hide so that your datatype is
opaque.
John
On Nov 20, 2008, at 1:50 PM, Rob Meijer wrote:
> I just watched a video on youtube about singletons and dependency
> injection.
>
> http://www.youtube.com/watch?v=-FRm3VPhseI
>
> It would seem that there are very high similarities at least between
> object capabilities and dependency injection. Does anyone know
> sufficient
> on dependency injection to compare it to object capabilities.
>
> It would, with my limited understanding of dependency injection seem
> like
> ocap languages would be the perfect way to do dependency injection.
>
> If the similarities are truly that big as they apear to be, couldn't
> dependency injection be a potential channel by what to promote object
> capability usage to a wider public?
>
> Rob
>
> _______________________________________________
> cap-talk mailing list
> cap-talk at mail.eros-os.org
> http://www.eros-os.org/mailman/listinfo/cap-talk
More information about the cap-talk
mailing list