Understanding Adapter Pattern Using .NET
page 5 of 15
by David Simmonds
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 53806/ 208

Scenario - Sample Code

I know I promised to give sample code which was different from the Real Life illustration, but I like this example so much that I am going to continue using it.

In the example we have a Windows Form representing the dashboard, gas pedal and wheel-turns of a car.  We start with the accelerator pedal which “drives” everything.  Sliding the horizontal scroll bar to the right simulates the pressing of the accelerator.  Behind the scenes and somewhere in imagination-land, there is a consequent increased revving of the engine, which turns the gears and makes the axle turn faster.  Since the wheels are connected to the axle, this should translate into increased ground speed.

The speedometer cable is connected to the axle and therefore spins as fast as the axle.  To get the speed we simply translate the revolutions of the speedo-cable to miles and its turn-rate to mph.

UML – General

Figure 1

UML – Sample Code

Figure 2


View Entire Article

User Comments

Title: its great explaination in detail about Adapter Pattern   
Name: Elan Emerging Technologies Pvt. Ltd
Date: 2010-01-18 7:05:35 AM
Comment:
its great explaination in detail about Adapter Pattern


Thanks,
Elan Emerging Technologies (EETPL)
http://www.elantechnologies.com
Title: Thanks   
Name: Rakesh
Date: 2008-12-08 2:59:28 PM
Comment:
Looking forward to read this article
Title: Very Understandable   
Name: Srilakshmi15
Date: 2008-05-11 7:19:36 AM
Comment:
Hi Simmonds
It's really good to understand without getting any confusion.
Thanks a lot.
Title: Not able to Download the Codes   
Name: Ritesh
Date: 2007-08-07 4:19:25 AM
Comment:
I am not able to download the codes of the above sample
Title: Great! Resouces.   
Name: .Net Developer
Date: 2007-05-14 1:56:04 AM
Comment:
It's Great Resouces for abt adapter pattern. I hope you will writing usefull .net articles in future.

Jim
http://www.tatvasoft.com
Title: its great explaination in detail abt adapter pattern   
Name: vamshi
Date: 2006-11-14 5:27:20 AM
Comment:
its great explaination in detail abt adapter pattern with a clear explanation -not found any where else. hope i will get other pattern too
Title: Adapter Explanation with real Time   
Name: Ranjith M
Date: 2006-11-03 4:03:56 AM
Comment:
Its realy cool.I went through lot of links i dont understand the pattern.The real time explanation is realy good one.Thanks a Lot.:)

Product Spotlight
Product Spotlight 





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


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-10-10 3:54:03 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search