>Technical – "Spring: A Developer’s Notebook"

>This book is from a new O’Reilly series, called “Developer’s Notebook”. The idea behind the series is to present some piece of software or a tool in a way a developer might want to see it. Basically, with all the fluff removed and just pure technical discussion on how something should be used. with lots of coding examples. The book even looks like a notebook, with fake coffee stains and post-it notes on the cover. So far I have seen maybe five or six books in this series.

The book I read is “Spring: A Developer’s Notebook”, which covers the Java Spring framework (I know, a big suprize). What is the Spring framework? The official, buzzword compliant, definition is that Spring is a “lightweight container”. In plainer language, Spring is an enviroment for running Java applications. Spring provides number of services (such as security, transactions, remoting etc) that are often provided by the heavy weight J2EE application servers (like Weblogic or Jboss), but without forcing your application program into a heavy J2EE type structures (EJBs etc).

Spring gains a lot of its power from few very simple concepts. The first one is a design pattern called Inversion of Control (IOC) or sometimes called Dependency Injection. This is a fancy name for using Java interfaces to decouple components of your system. Spring provides facilities where interface implementations are configured via XML, and objects are connected by Spring during system initialization. This connecting is called “dependency injection” – I think Martin Fowler came up with this term. Don’t blame me.

The use of IOC is illustrated to the n-th degree throughout. The book consists of a graduated example. As you are reading the book you can actually implement the example and have running program at the end of each chapter (I didn’t do this). The book’s example is a system to manage a bicycle rental shop and the class that implements the storage of bike information is implemented in several different ways – depending on how we plan to store the data – and is “injected” into the system at startup time.

Another big advantage of using Spring, is that the application objects are POJOs (“POJO” means Plain Old Java Ojects – who comes up with these?!), that is they are not required to implement any weird interface or extend any container classes (as you would under Weblogic let’s say). This makes automated unit testing a lot easier. Again, nearly every chapter includes some unit test examples (see JUnit and continous integration if you want to know more about testing).

The other big part of Spring, that makes it much easier to use, is the AOP framework (AOP stands for Aspect Oriented Programming). With AOP you can insert code into exiting system to do stuff like manage transactions, or handle security, without the need to touch the basic objects of the application. One of the central ideas of AOP is that a call to method can be intercepted and something can be done either before or after the method runs. The cool thing about the Spring’s AOP is that although the interceptor code has to be written in Java, the insertion into the system is done via XML configuration.

In any case the good thing about “Spring: A Developer’s Notebook” is that it contains only the meat of the subject. There is no unnecessary narrative on the history of Spring, or definitions of XML, or what OR mapping is. Things that you’d expect the reader to know. Instead you have a worked out example that demonstrates the key concepts of the framework, and if you work through it yourself at the end you will gain a deeper understanding of the topic.

After having been stuck with needing to read 400 page technical books, which are 80% useless fluff, it’s a pleasure to read a book like this. But again, since this is an O’Reilly series I’m not suprized. I already started to look at developer’s notebooks on “Hibernate” and “Java 1.5”.


One thought on “>Technical – "Spring: A Developer’s Notebook"

  1. Pingback: Technical Reading | Pirx2691

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s