Meeting 5

Aus Java Student User Group Austria - Java + JVM in Wien Österreich / Vienna Austria
Wechseln zu: Navigation, Suche

When: Monday, October 13th, 2008 - 19:00

Where: Freihaus HS4


Inversion of Control

Download the slides (pdf, 38KB).


Florian Motlik introduced todays topic IoC, which follows the slogan "don't call us, we'll call you". Your code just implements the specific logic but the actual control itself is passed to a certain controller class. A trivial example would be iterating over a collection.


Instead of writing ...

var someList = [ "Larry", "Curly", "Moe" ];
for(var i = 0; i < someList.length; i++) {
  var name = someList[i];
  println(name.length);
}

... one could just say ...

[ "Larry", "Curly", "Moe" ].each { name | println(name.length)}

... and that's all. By passing a function to a certain method provided by the datastructure itself (make use of closures), the actual iterating over each field is hidden and you don't have to worry about it anymore; your could will be invoked for each item, and therefore control is inverted.


Dependency injection (originally introduced by Martin Fowler) is a specific form of IoC. Dependencies of a class will be injected for you (constructor/setter/field injections are possible) and therefore the coupling is not necessarily reduced, but its shifted outside the code (in case of Spring into a XML file).


Guice

Download the slides (pdf, 115KB).
Download the sourcecode (pdf, 13KB).

Content

Held by Jan Zarnikov

Links

Springframework

Download the slides (pdf, 0.6MB).

Content

Held by Christoph Pickl.

Links


Gallery

Thanks to Jan for providing these pictures.