This is Reza! I am a software developer and architect mainly on Java/EE. Here you can find links to my writings, photos etc. My areas of involvement are software development, design and architecture. I am also interested in and study about open source, distributed systems, software metrics, patterns, architecture, methodologies and mathematics. Reza has posted 3 posts at DZone. View Full User Profile

Java Frameworks and Pattern Usage by Developers

  • submit to reddit

A couple of days ago I was thinking of the last time I used a pattern in my daily programming. I think it was 3 months ago! Then I tried to find out why.

What I mean about a pattern is a GOF or J2EE pattern for example. I am not talking about very basic patterns already embedded into programming languages like interfaces, accessor methods, private methods, etc.

As many other developers do (at least in the Java world) I use many open source frameworks such as Hibernate, Struts, Spring and now I am thinking that these frameworks make me use less patterns in my day to day developments! Although they are great tools and make programming hundreds of times faster, they stop developers to use (write) patterns in some areas since they carry the burden of writing those patterns themselves.

Don't get me wrong, working on a project you might still need to use (write) many patterns, depending on the size and complexity of the project, but many other patterns may be hidden by the framework and you do not need to use them because the framework has already done it for you. In many cases you just write some code on top of that pattern the way you should do it in that framework's specific way.

Also, most of patterns are written when the project is in early phases of development and the architecture is shaping. After that people need less usage of patterns. Writing the architecture or reference use-cases is usually the responsibility of senior developers or architects and other developers are not very exposed to these areas where more patterns are being applied.

Lets see an example. Imagine a simple web based project with a couple of database tables, some CRUD and a bit of security. Suppose you want to write this with hibernate/Spring or iBatis/Struts with Acegi. Using all that you might need some DAO, Value Object, Controller and some more. Using all these will free you from many complications.

But suppose you do not want to use any framework. Think of Sun's Pet Store example which is all plain. Definitely you need a hand full of patterns if you want to write it in a proper way. specially most of presentation tier patterns are hidden (such as Intercepting Filter, Context Object, Application Controller, View Helper,...).

I see the point of all frameworks as:
  1. Faster Development
  2. Developer focus on business
  3. Other things!

Having these points in mind we see that a framework developer wants an application developer just to focus on business development not the underlying technology. This is good in the sense that you do not need to struggle with the technology but (in the context of our discussion) there are some problems with it:

  1. Developers will not use most of the patterns
  2. Developers become lazy
  3. Developers will not learn bits and pieces or tricks of the underlying technologies

Well, we cannot stop framework development! I have also been developing some myself. They are good for their objective but have side effects.

Looking at the popular frameworks we see that they are full of patterns and tricks that a programmer can learn about but if you don't care about these things and just develop a design given to you then you will not learn the inside. As a good starting point I always suggest programmers to read frameworks codes. This way you will learn a lot of things and also you will know the way that framework behaves and will use them confidently.

I know the whole subject is relative so do not reply me saying that we are using patterns all the time!

Published at DZone with permission of its author, Reza Ghafari.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)


Mittal Bhiogade replied on Fri, 2008/05/30 - 8:12am

This shall always be factor for debate like Old School Vs New School Java Developers. Developers like me who started writing java code in mid/late-mid 90's Vs developers starting out now using frameworks and Spring from day-1 of thier developer life - may miss all under-the-hood learning action.

Thanks, Mittal

George Jempty replied on Fri, 2008/05/30 - 12:56pm

How does a framework help me deal with objects that I need to act on differently when they are in different states? I encountered this problem a couple of years ago, on a Struts/Hibernate project, for the author of Programming Struts. So I implemented the state pattern, so that I could call certain methods on a PlacedOrder, but other methods on a ShippedOrder. No framework is going to solve all of your problems.

George Jempty replied on Fri, 2008/05/30 - 12:57pm in response to: Mittal Bhiogade

Too many "old school" Java developers only know how to use Vector and have no clue about the Collections API.

Mittal Bhiogade replied on Fri, 2008/05/30 - 1:09pm in response to: George Jempty

And this comments is based on whaaaat ???

George Jempty replied on Fri, 2008/05/30 - 2:33pm in response to: Mittal Bhiogade

On my own experience, within the last month or two, at my current job.

Lieven Doclo replied on Sat, 2008/05/31 - 4:29am in response to: Mittal Bhiogade

Regarding you statement on new-school developers, you might be correct. But it all depends on how well motivated a new developers, submerged in Spring from day one, are. Must developers I've met so far are new-school (I myself included), and you've got two sorts: one sort just works with the framework, the other jumps into the underlying code trying to figure out how something works.

Also remember, sometimes new-school developers need to work with code written in the mid/late 90's (due to the current market), and believe me, sometimes you don't want to know the under-the-hood stuff :), and the learning lessons you get you may not want to retain..

 Otherwise, great article. Hit the nail on the head.

Steve Westwood replied on Wed, 2008/06/04 - 3:05am

Interesting article, lots of good points made.

Those of us involved in development prior to the proliferation of frameworks were almost obliged to get to grips with patterns just to make life easier and improve code quality. I think you are correct in suggesting that frameworks often reduce the need for patterns, however I tend to find that those with a pattern background are often in a better place to exploit features frameworks. Lets face it , with the Spring Framework, you would not get very far with without an appreciation of what a Singleton gives you...



Des Oates replied on Wed, 2008/06/04 - 4:39am

If you're tasked with making widgets, patterns give you the blueprints to help you make widgets . Frameworks give you widgets- or the widget components- ready-made :-)

Whether or not you use patterns in your code is not necessarily a reflection on your coding abilities,coding style, or even of the age of the 'school' to which you belong. It's a reflection on the nature of the problem your code solves, and the overall solution architecture. I agree that developers who have a solid understanding of key patterns are better positioned to re-factor code into something more elegant and maintainable , but that doesn't mean that they must use that skill if there no real need to apply it right?

EG replied on Fri, 2008/06/06 - 4:07pm


There are also Frameworks that help you design/implement software based on Design patterns (GoF, J2EE, MVC, DAO, etc).

Please refer tthe Jt Pattern Oriented Framework:

Dileep Donepudi replied on Fri, 2010/05/14 - 12:49am


i am J2EE learner i need one project for my job search

will u pls provide 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.