Tuesday, August 30, 2005

MVC using Spring

I started exploring the Spring Application framework yesterday and am very impressed by it. Not only does it let me create much simpler J2EE applications but it also decouples components pretty neatly. For this it uses the principle of inversion of control. I plan to use this excursion of mine to learn come concepts like inversion of control, learn frequently used features of Spring (like using a database and remoting) and brush up my newbie skills of JSTL etc.

Some ideas of Spring which really impressed me:
  • Code should be easy to test. Because we develop Spring applications with JavaBeans, testing is cheap. There is no J2EE container to be started since we will be testing a POJO. The application context can be loaded outside of a web server environment using a class that will load an application context. There are several available, and for the current task I used the FileSystemXmlApplicationContext. This loading of the context is done from directives on XML prperty files. This itself wins me over. The simplicity of testing like this cannot be overstated. Of course it does have its disadvantages but for individual POJO testing which are deployed inside an application server context I think this implementation is hard to beat.

  • JavaBeans loosely coupled through interfaces is a good model. With Spring, your beans depend on collaborators through interfaces. Since there are no implementation-specific dependencies, Spring applications are very decoupled, testable, and easier to maintain. And because the Spring container is responsible for resolving the dependencies, the active service lookup that is involved in EJB is now out of the picture and the cost of programming to interfaces is minimized. All you need to do is create classes that communicate with each other through interfaces, and Spring takes care of the rest.

At some point I plan to use Hibernate as the persistence engine in place of the default HSQL.

For newbies to Spring I would suggest two resources:
The excellent bootstap guide to Spring.
The book: Spring in Action

Disclaimer: I am experimenting with MVC implementation technologies and Spring is new to me.

Tuesday, August 23, 2005

General Musings

Sorry everybody (yeah I know that means nobody). I was pretty busy last few months. Went to Boston on a business trip last month and have been catching up with "stuff" since then. As is evident this post is mainly about thoughts I want to record for posterity sake which have come to my mind over the last few months.

Lately I have started investing in value stocks in India. I spend time reading classics like Security Analysis and The Intelligent Investor. I feel that not much has changed in the business of value investing since 1971 when the Graham first wrote this tome.
The principles are the same, only there are some new industries now to look at. I think there is a lot to be understood from this book.

Also I am returning back to coding on the side as often as possible after the intermission of two months injected because of the trip and other associated activities. I guess this gives me immense satisfaction apart from other benefits.

Last weekend I went for the engagement ceremony of one of my friends whom I have known since my 8th grade. A couple of us old friends got together and caught up with each other and about others who could not make it to the event. We had a ball of a time. I was pretty surprised by how many friends of my batch are married, some even have kids.

really liked Martin Fowler's latest entry. He does explain a not-so-trivial topic with simplicity and clarity. I guess this comes with experience and clarity of thought. Thats the reason I like Head First people too. I also feel that Sealing should be avoided as taking responsibility of code (not breaking something) is basic principle and one need not tell this explicitly (using Sealing) and reduce the flexinility available to a sub-class writer. Also I hope to see anotations being used more and more extensively in java.