Sunday, August 17, 2014

Patterns not a Panacea

Patterns are good as they capture best practices but most of the time we try to fit those patterns to solve our problems. Sometimes we even fit our problems over our solutions or so called patterns. We can take the famous example of EJB2.1 entity beans where we have DTO patterns to move the object across the wire. And lot of us take pride in knowing that we know about DTO's and have used it. Don't worry, even I was also one of them. Now take a step back and see that we were solving the basic problem itself the wrong way. The basic problem was that of handling the notion of persistence itself which is fixed in the EJB3.0. The artificial problem went away automatically. Of course we should congratulate hibernate also for showing the right path.


I think we should promote more basic thinking among developers. Rather than trying to figure ourt where we can apply the patterns we should start thinking about the problem that we are trying to solve. We should promote thinking, which happens at basic notions of object oriented programming which are abstraction, encapsulation, inheritance and polymorphism. I believe abstraction is the most powerful of these notions and probably most difficult to master. Abstraction is the basic bridge between software world and the business/real world. The other notions help us in building the structure and detailing of the representative software world that we create.


The important thing is to understand your problem. Knowing the problem that you are solving is half way to the solution. Otherwise we will try to put a square peg on a circular hole. If fact, in any software design problems, start with what we are trying to achieve and then once that is clear think about what are appropriate tools (patterns) to solve them.

No comments:

Post a Comment