• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

About Adapter pattern

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All
I am reading about adapter pattern from design patterns book and it says
intent of adapter pattern is
"Convert the interface of a class into another interface clients expect".
Is this means, we implemented our application according to some third party intrfaces and if there is a need to chage those interfaces we can use a adapter to convert the new interfaces as old,which client expects??
Please correct me if my understanding is wrong??
Can you please explain me in what conditions we can really use adapter pattern???
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You've got the right idea.
Here's a simple example of the Adapter pattern.
 
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If we have different third party products to choose from at runtime, we will be having respective adapter objects all of which support a common adapter interface held by the client. Hence the adapter object chosen at runtime will adapt the third party interface to the client's expected interface.
 
Radha MahaLakshmi
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Is there any book or site which explains the patterns in terms of real life implementations??? or explains the patterns with simple examples???
i am reading the GOF book but the i am not able to understand the examples clearly.
for bridge pattern can you give me a simple example as you have given for adapter.
Regards
Radha
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would recommend grabbing Applied Java Patterns, which presents the GoF patterns in Java.
 
Jayadev Pulaparty
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Radha MahaLakshmi:

i am reading the GOF book but the i am not able to understand the examples clearly.

Regards
Radha


Design patterns are applied to a problems in a particular context. Hence reading it abstractly from the GoF book is not the best approach IMO. I too did the same to start with, but then saw some practical scenarios in Larman for UML. The following link has a good collection of related resources.
http://www.cetus-links.org/oo_patterns.html
 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think "Applying UML and Patterns" by Craig Larmen is probably the best book to look at practical scenarios where UML and patterns can be applied(especially for beginners.It's not a comprehensive book on UML or patterns).
It also explains Rational Unified Process.
For more info and sample chapters:
www.amazon.com/exec/obidos/tg/ detail/-/0137488807?v=glance
 
Jayadev Pulaparty
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
True. Larman is a very good book. But the only problem is that a new person cannot just open the patterns topic in there and start reading it. The book explains the unified process in chronological order with a POS (point-of-sale application) example,and most of the situations in which the patterns are explained are dependent on understanding a little more about that example application.
I have this document with me which gives a good conceptual look at design patterns -
http://www.agcs.com/supportv2/techpapers/patterns/papers/tutnotes/pattern_examples.pdf
[ September 18, 2003: Message edited by: Jayadev Pulaparty ]
reply
    Bookmark Topic Watch Topic
  • New Topic