Friday, January 29, 2010

Learning Java? Look at Spring

For those that are learning Java, or those that want to improve their skills, I highly recommend learning about the Spring framework.

Initially, just using it will help enforce good design principles within your applications, but if you want to truly grow as a developer (and designer), you should dig into the details and understand the implementation of Spring. It applies good design principles consistently (like separating interface from implementation), and can be a good reference for understanding how to use design patterns. For example, JdbcTemplate is a classic use of the Template pattern (or Template Method, depending on who you ask).

In fact, the JDBCTemplate is probably the best place for those that are new to Spring to get started. It is a valuable addition to most applications that use JDBC, even if no other Spring services are utilized. It can be a straightforward introduction of Spring into an application (or even an organization). It really simplifies the use of JDBC by handling much of the common plumbing work that is required, and lets the developer focus on the business logic.

By understanding how these patterns are applied within Spring (and the the problems that they are solving), you will begin to recognize similar problems in the applications that you build - and apply the appropriate patterns to solve them.

Its as simple as starting with the javadoc to look at the class structure and hierarchy, but I would encourage you to go further and actually step through the running code in a debugger to be sure that you understand the call path - I have always found the debugger to be an invaluable resource when trying to understand code behavior.