Design Patterns in VB.NET
page 2 of 4
by David Simmonds
Feedback
Average Rating: 
Views (Total / Last 10 Days): 27619/ 43

Parts of a pattern

Before we can go into the parts of individual patterns, it should be mentioned that the GoF categorized the 23 patterns into Creational, Structural and Behavioral patterns.  This helps us to think of patterns among their peers, whether they instantiate classes for us, arrange the classes into useful structures for us or help the classes to collaborate at run-time in the most useful way.  This allows us to categorize our thinking broadly.

The GoF break-down each pattern into 4 major parts.

1) As the GoF point out, the design patterns are described in terms of their name, which allows us to get a quick handle on the general structure and interaction involved.  This is similar to automobiles where, instead of talking about “the device for cooling water coming from the engine through the use of the electrically-powered air-turning implement,” we can simply talk about the “radiator” and “fan.”  So the name is very powerful since it lends itself to a natural association with a mental image of how the pattern operates and also suggests how the pattern is internally arranged.  As they also point out, the names provide us with a common vocabulary for discussing the patterns.

2) The problem is similar to a description of the problem for which an auto part is used to solve.  For example, brake-pads are required for providing the functionality of stopping and radiators are useful for cooling the engine due to the heat given off.  Electrical relays help us to deliver current in a manner which isolates the switch circuit from the circuit which actually does work (such as a horn or starter), so that we reduce the risk of being shocked or setting fire to the car due to an electrical short circuit.  Similarly, the design pattern problem is a scenario that requires a methodical approach in which the interaction of the classes in the pattern provides functionality that addresses that problem.

3) The solution helps us to understand how the classes and objects in the pattern instantiate, compose, interact with and pass messages to each other in order to solve the problems faced in the particular circumstances.

Let us revisit the radiator.  A radiator usually has pipes leading hot water to it and cold water out of it, tubes for leading the water up through fins.  These fins provide a greater surface area for the fan to blow air through in order to cool the hot-water.  Not terribly different from the setup of the CPU-fan/heat-sink in your PC, the arrangement and internal interactions of the radiator represent a solution to the problem of heat exchange.  In fact, heat transfer systems everywhere have come to use this elegant arrangement of collaborators; this includes A/Cs, fridges, radiators, heat-exchangers in Power stations, etc. It just goes to prove that once a solution to a known problem has been designed in a simple, cost-effective, recognizable and reproducible way, people will tend to learn and implement it without fail (hence the adage – “Don’t reinvent the wheel”).

Now just as the radiator:

·         Is an arrangement of smaller parts (which):

·         Carry out responsibilities in sequence (hot water pipe, tubes, fins, cold-water-pipe)

·         Communicate messages to each other (using water)

·         Activate other components (cause the fan to spin)

·         Instantiate other objects (Check Engine warning)

 

Similarly, the classes and objects in a design pattern all have a responsibility for acting out the solution to the problem in the OO design space.

 

4) Consequences help us to understand the costs involved in implementing the pattern so that we can avert as much of the cost as possible without compromising pattern-safety.  Picture a relay that helps us to isolate high-current circuits from circuits, which the driver may operate through a switch interface.  While the relay is very useful, the fact is that the relay is an extra circuit to wire, an extra component to fail, more space taken up in the engine bay, another circuit to maintain and generally represents extra cost to the owner. The consequences help us to understand how patterns affect the cost of building the software, the performance impact and how to minimize them, etc.  It also describes how the different trade-offs affect the extensibility we eventually achieve.  Therefore in engineering terms, it shows how we can optimize the interactions of the classes in the pattern.

 


View Entire Article

User Comments

Title: Code samples   
Name: Mike Angelastro
Date: 2008-05-12 10:13:13 AM
Comment:
What is a good source of VB .NET code samples for the design patterns?
Title: How do design patterns fit with SOD/SOP   
Name: Mike Angelastro
Date: 2008-05-12 10:10:30 AM
Comment:
How do design patterns fit with Service Oriented Design/Service Oriented Programming? The underlying principles are similar.

Another metaphor is a schematic diagram of an electronic circuit or logic circuitry. These explain how item is put together.
Title: Response to Estevez - Part II : Philosophy of Design Patterns   
Name: David M. Simmonds
Date: 2007-05-21 3:26:11 PM
Comment:
On the other hand, design patterns do have a very philosophical basis. The philosophy which applies to design patterns (and undergirds many religions) is that if you delay gratification (in this case the implementation of the software) and put more work into the design upfront, then you reap less pain overall and in the long run (maintaining one aspect of the system does not mess up other parts of the system). Modifications can be done painlessly and cheaply without testing every other feature in the software. Hence programmers would be involved in less "software crises".

Anyway, watch for the day when the due diligence (which is done leading up to a corporate merger/buyout) includes a software design review which determines whether the mergee has software built using design patterns. At that point, you are going to see just how tightly intertwined philosophical issues and Dollar issues can be.
Title: Response to Estevez   
Name: David M. Simmonds
Date: 2007-05-21 2:04:47 PM
Comment:
In response to Estevez:
"I think Design Patterns are an philosofic part
of programming, can't see any worth of using it."

My response is, TRUE !!! Especially if you work in your IT department's Pre-Requirements-Change unit (the Software-Development counterpart of the Pre-Crimes unit as portrayed in "Minority Report")

In other words, if you are a precog and you can read the user's minds from the day you collect User Requirements in order to do your Software Specifications, then you will never need to modify functionality in your software or add features to it. So you are right, why spend all of that effort designing the software to make it easy to extend or modify when it never needs to be modified or extended?
Title: Art of programming   
Name: Estevez
Date: 2007-05-18 5:11:20 PM
Comment:
I think Design Patterns are an philosofic part of programming, can't see any worth of using it.
Title: nice Analogy   
Name: Amos
Date: 2007-05-10 6:05:32 PM
Comment:
The way to use a car and car industry to illustrate patterns and software kick-ass.
Title: Perfect WHY article   
Name: Vin
Date: 2007-04-13 3:58:52 PM
Comment:
Everyone will be motivated to learn about design patterns after reading this article
Title: Easy to Read   
Name: Mayank
Date: 2007-02-16 11:46:26 AM
Comment:
The article is very well written & informative. It deals with a complex subject in a very lucid manner. Expect more such great articles in future.
Title: Look forward to more in the future   
Name: Ben
Date: 2007-01-29 6:41:04 PM
Comment:
Great article, I enjoyed it very much. Hopefully there will be follow-up articles with even more detail!
Title: Fantastic :)   
Name: Kris
Date: 2007-01-26 7:40:12 AM
Comment:
Very elegantly described and introduced to design patterns.
Probably also listing what excatly are 23 patterns defined, would make this article more informative
Title: So cool   
Name: Luis Vega
Date: 2007-01-23 5:19:38 PM
Comment:
Excellent Article, I want to read more.
Congratullations
Title: Good Analogies   
Name: Ali
Date: 2007-01-18 5:01:33 AM
Comment:
Great article! Very very nice real world examples. I am expecting great articles regarding this article in future.
Title: Solar System   
Name: Miri Davidian
Date: 2007-01-15 9:17:29 AM
Comment:
Dear Sir,

I have a question.
I would be grateful if you would help me.
What would be the design patterns solution for solar system?
The Sun, is obviously singleton.
The plans are obviously factory.
But, when it becomes to the stars,
I wonder what they are.
On one hand, the stars are factory for the sun;
on the other hand each is a singleton for his own plans.
So, what are they?

Many thank in advance,
Miri
miridavidian@gmail.com
Title: very good   
Name: Rushikesh K Khairnar
Date: 2007-01-07 1:35:09 PM
Comment:
Simple and informative
Title: Nifty   
Name: Denny Jacob
Date: 2006-12-27 3:48:46 PM
Comment:
Simple, flowing and not one wasted word. I wish more of us had this pattern of writing!!!!
Title: Very Good   
Name: Pandi
Date: 2006-12-26 12:01:56 PM
Comment:
It was very good to a new person who wants to know about Design patterns.
Title: many thanks   
Name: Monica
Date: 2006-12-18 11:58:07 AM
Comment:
clear view of how design patterns came to light!
Title: Tanks   
Name: Shaik Kaleelur Rahman
Date: 2006-12-18 5:32:27 AM
Comment:
Very Nice Article
Title: Well Done - Three Cheers   
Name: Rajeev Gopalakrishnan
Date: 2006-12-12 4:10:56 PM
Comment:
Wonderful, my friend, wonderful! I can't say that any more louder!!
Title: cool   
Name: shubha N
Date: 2006-09-11 5:44:18 AM
Comment:
this artical is very informative
Title: very informative   
Name: gowri shankar
Date: 2006-09-11 5:42:53 AM
Comment:
it was very informative good work
Title: Nice   
Name: Veeru
Date: 2006-08-25 8:58:23 AM
Comment:
This very nice,very useful to every one,and this is a wonderful job......
Title: KISS   
Name: George
Date: 2006-07-27 11:34:53 AM
Comment:
Keeping it Simple and Straight. A very refreshing article, waiting to see more of this... Great job
Title: Plain and Informative   
Name: Mehdi Anis
Date: 2006-07-21 3:51:23 PM
Comment:
I enjoyed reading this article. nicely written delivering good information. Thanks.
Title: Cool   
Name: Ed
Date: 2006-07-18 7:48:51 AM
Comment:
Great Article. Very useful. Wonderful job
Title: Cool   
Name: Ed
Date: 2006-07-14 6:03:56 PM
Comment:
Great Article. Very useful. Wonderful job!!!

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-03-19 6:01:33 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search