Sunday, June 04, 2006

Why not integrate design patterns directly into java language?

I have been doing java programming for over 5 years now and trying these days to understand the design patterns better especially the ones proposed by gang of four. The more I read these design patterns the more I feel that these patterns should have direct support in the java language (and for that matter any OO language). I mean think about this for a minute why not let the language evolve in the direction of best practises by building the same into it so that there is less and less scope for doing things wrong. I believe that if there are more than one way to do something and a particualr way is a design pattern or best practices than it should be directly built into the language as default and if someone wants to use some other way than he has to follow extra steps to do so. Today you have to follow extra steps to do the right thing.

I am hoping to post my thoughts on each pattern as I read more about it. Some initial thoughts are as follows. Take Observer design pattern, it is currently built into java which is good. The Singleton design pattern support is somewhat provided by java's static keyword but should be expanded so that it is not required to worry about doing those extra steps of making the constructor private and providing getInstance() method or front it by Factory pattern and so on.

No comments: