“What do
you understand about design patterns from the past nine months of code
that you've written?”
This was the question put to me by my
manager in today's meeting. The question was sudden and to be honest,
I fumbled for words. I uttered few random sentences including the
phrases “style of programming”, “the best way to apply a logic
out of all available ways to do so”, etc. (which were pretty lame of course)
Now, I sit back in peace and try to fathom about design patterns based on my nine months of programming experience in the corporate world. When I try to rephrase the answer for the question, I find that I am really out of words to exactly describe what a design pattern exactly is, which is So in contrast with the ease with which the Gang of Four describes them to be.
From my
understanding, I put it this way,
“A design pattern applied is
THE possibly best fit (or the most optimized if not the best)
approach that you adhere to while programming to find solution to a
problem that you are trying to solve.” It is more generic a term
and has got to do little or less with the specifics of a programming
language used except for that it is widely used within the scope of
Object Oriented Programming.
From what I understand, I believe and will continue to believe so, that, a design pattern is not limited to the few available standard textbook patterns like the factory pattern, singleton pattern, et al as suggested by the GoF. There can always be a pattern that is not a standard, is nameless and self defined, yet best suited for the task that you are working on. All the standard textbook patterns available can be safely regarded as hints to the problem you solve. Why I call it a hint more than the solution itself is that sometimes the pattern might just fit in so perfectly to a business scenario but sometimes it might not, Nevertheless it will take you closest to implementing a best solution to that problem.
My
experience limits me to very few design patterns that I've worked
with till date like the observer pattern, factory pattern, the
yuckiest singleton pattern, etc but I guess this is what a design
pattern is if you ask me, of course, from a noob's perspective.
Good
that this post will not allow me to embarrass myself again by
fumbling for words to phrase an answer when asked the same question
and hopefully, at least in an year or two, I hope that I'd be in a
position to answer any design pattern related question even in the
midst of the midnight hour. Amen!
0 comments:
Post a Comment