Hmm..what pattern will you use here?

Design patterns are cool. Umm… what does that mean. At the vending machine in office, developers love to get into discussions about how they used State pattern and rescued the project. Young grasshoppers like me love to read some book or blog and think how could I make use of this newly learnt “thing” in my project. Recently our company hired a “super software guy”. He was something like 35-40 years experienced in the industry, carrying with him a whole bunch of presentation slides and a huge set of his own rules. Basically he was one of those Architecture Astronauts. I highly recommend reading Joel’s take on such people especially for young grasshoppers like me who are at a stage where Lead position is soon to come. I had asked a quite honest (I think) question to the lecturer about the way I think about design patterns in a project. I said, when I look at a problem in my project, a coding problem, I think, what pattern can help me here. Then I go home and open my “Head First Design Patterns” copy and see if something strikes me. Am I doing the right thing? He said Yes. He added that is really how one should code in a project.

I have utmost respect for the lecturer and for his immense experience in the field, but after spending some time reading blogs, books by some industry experts, I think the lecturer completely missed the point. Design patterns are recurring solution to a recurring problem, they are industry wide accepted norms. But they do make things complicated. In several simple scenarios, implementing patterns mostly leads to more code which causes unnecessary maintenance problems. The idea should be to solve the problem in the simplest possible manner, which keeps the code clean, taking care of common OOPS principles like cohesion and coupling. If proper thinking is done, you would end up with a solution probably close to some pattern that already exists. But there is absolutely no need to think of a pattern as soon as you see a problem.

If programming was as easy as finding a design pattern for a problem then I think I should quit my job and live in a van down by the river eating a steady diet of government cheese.

Happy Programming!