Click here to Skip to main content
6,822,613 members and growing! (22,812 online)
Email Password   helpLost your password?
Development Lifecycle » Design and Architecture » Design Patterns     Beginner License: The Code Project Open License (CPOL)

Design Patterns - a deep dive 1

By Sunny Chaganty

A colleague of mine asked me a question few days back: "If an application is created using the correct design patterns, does it ensure that the application would be bug/performance issues free?"
C# (C#1.0, C#2.0, C#3.0), Windows, Mobile, ASP, ASP.NET, WinForms, WebForms, Ajax, Architect, DBA, Dev, Design
Posted:28 Jun 2008
Views:13,573
Bookmarked:31 times
Unedited contribution
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
17 votes for this article.
Popularity: 3.32 Rating: 2.70 out of 5
4 votes, 23.5%
1
4 votes, 23.5%
2
5 votes, 29.4%
3
2 votes, 11.8%
4
2 votes, 11.8%
5

A colleague of mine asked me a question few days back: "If an application is created using the correct design patterns, does it ensure that the application would be bug/performance issues free?"

The answer to the question gave me an idea to put in a series of articles to look at what are design patterns, what design patterns can/can't do & hopefully get some interesting dialog started with you readers about your experiences & inputs.

Let us start this journey with a small step in understanding a few definitions regarding design patterns, and look at what design patterns are all about at a very high level. The subsequent articles will focus on details of each pattern & a few scenarios where we can use these patterns.

What is a design pattern?

"In software engineering, a design pattern is a general reusable solution to a commonly occurring problem in software design" - (Wikipedia, 2008)

IMHO, a design pattern is a probable way to solve a design problem in software. I use the term "probable" because even though a design pattern might "seem" to solve the issue you are facing, you still need to analyze the problem & ensure that the solution/pattern offered is valid in the context of your development effort.

This judgement is acquired only by experience in either using the pattern successfully or having burnt your fingers in the process. Experienced Architects, Designers & Developer will tell you that even if you have had used a pattern many times in your previous projects, you will still need to evaluate using the pattern in your current project simply because the requirements/project environment/time-of-the-day is different from the last time you used it.

"Patterns are about design and interaction of objects, as well as providing a communication platform concerning elegant, reusable solutions to commonly encountered programming challenges." - (Data & Object Factory, 2008)

The key word in the definition above is the idea of a "communication platform". A design pattern not only helps in communication between objects, but also provides a communication platform in discussing your ideas with your peers.

For example, it would be easier in telling someone that you are planning to use a Facade pattern instead of a MVC & they would instantly know the "structure" of what you plan to do. So you could directly get into a discussion about the merits/demerits of using a particular pattern & focus on what meets your business requirements rather than spend time explaining what you plan to do.

Note: The above statement is assuming that the "someone" also understood design patterns; else you can always point them out to this series for more information :P

What is NOT a design pattern?

These are a few items that come to mind & I will keep updating this list if you have some more items to add here. So, here goes:

  • Design patterns are not architecture patterns - design patterns specifically deal with the problems at a software design (object creation, communication & behavior) level, while architecture patterns deal with the problems at the software engineering (communication, operation, maintenance, enviroment, physical/logical layers in the application) level
  • Design patterns are not solutions to your problem - design patterns are generic solutions to generic problems. Your application is not a generic application, so if you need to "customize" a design pattern to solve the specific problem you are facing. This customization would be valid only within the confines of your application to address that specific problem. You will need to start this analysis all over again in a different problem/project.
  • Design patterns are not algorithms - design patterns are not implementations, they are only a "framework" for a solution, while algorithms are implementation of a problem solutions to a problem (update: thanks to Neni-san to point this out in the comments section). So, while algorithms may be directly used in your application (For example, an algorithm for a bubble sort), design patterns need to be tailored for your application
  • Design pattern is not a hammer looking for a nail
  • Design patterns are not answers looking for questions (this is a good quote from my friend & colleague Vasanth)

Why do I need design patterns?

Frankly, you could continue with the rest of your programming life without knowing a single design pattern & you could do just fine. As long as a piece of software meets its business goals, who cares what it does under the hood, really?

The again, do you see a productivity benefit in using a proven development paradigm instead of re-inventing the wheel (unless the wheel was square, ofcourse)?

Would you prefer eliminating those hard to fix logical bugs in your application by using a standard template of avoiding such issues?

Do you like to appear cool (or a nerd, depending on the audience) by explaining the nuances of MVC/MVP patterns, or start a flame-war if MVC is really a design pattern or an architecture pattern?

If your answers to the above questions is a resounding YES, then unfortunately you do need to know what design patterns are.

On the bright side - you now have a new way to screw up your code & people might actually understand where you screwed up & help out with solutions!

Great, when do we start?

If you still didnot notice, we are already on our way!

This was the first of the series of articles & I hope to bring out the next one ASAP. Till then, you could go through my previous articles, which really have no connection to this article whatsoever, but interesting enough, I hope.

The Answer

Regading the answer I gave my colleague to his question posed at the start of this article, I realized that my colleague had two positives going in his favour:

  1. He realized that all software projects inherently had bugs/performance issues in them - to a detected or un-detected extent
  2. He was curious if his new-found knowledge could help him solve these issues
Since two positives still make a positive, I had replied: "Yeah, right!"

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Sunny Chaganty


Member
Sunny is the founder of IT.Wox, always (www.itwox.com) - a web application design, development & consulting company
Company: IT.Wox, always
Location: India India

Other popular Design and Architecture articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 15 of 15 (Total in Forum: 15) (Refresh)FirstPrevNext
GeneralWao .. Pinmembermanas0:03 11 Sep '09  
RantBoring......but nice try! Pinmemberdrm99889126:48 6 Jul '09  
GeneralThanks for your comments & feedback PinmemberSunny Chaganty8:10 2 Jul '08  
GeneralWell... PinmemberUncle Serge23:38 1 Jul '08  
Generalgood article Pinmemberhongshun_198222:21 1 Jul '08  
GeneralGood Article PinmemberMoRiKa22:17 1 Jul '08  
Generalnice one PinmemberHaja22:08 30 Jun '08  
GeneralRant :) PinmemberNeni-san23:06 29 Jun '08  
GeneralRe: Rant :) PinmemberSunny Chaganty7:09 30 Jun '08  
GeneralA usefull article. Pinmemberadamzhang21:26 28 Jun '08  
Generali hate links Pinmemberlemravec10:56 28 Jun '08  
GeneralRe: i hate links PinmemberSunny Chaganty18:28 28 Jun '08  
GeneralGood start PinmemberRay Cassick9:48 28 Jun '08  
GeneralRe: Good start PinmemberSunny Chaganty18:20 28 Jun '08  
GeneralRe: Good start PinmemberJuy Juka20:56 30 Jun '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads.

PermaLink | Privacy | Terms of Use
Last Updated: 28 Jun 2008
Editor:
Copyright 2008 by Sunny Chaganty
Everything else Copyright © CodeProject, 1999-2010
Web19 | Advertise on the Code Project