Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Adapter based on Dynamic Proxy

 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anybody else think Adapter based on Dynamic Proxy is way cool? Heinz Kabutz is often pretty far out there.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a quite valuable technique, yes.
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The benefits of this solution does not outweigh the complexity of the resulting code. Also, remember whenever you are using reflection the debugging becomes very difficult.

Most of the time, the elegant solutions are simple and powerful that solve a complex problem.

The author agrees that it is very rare that the interface will be changed by Sun. It is easier to just rewrite the code for the new interface rather than coming up with a complex solution.

The coolest Adapter Pattern that I have seen is shown by Mr. Dan Becker

http://www.javaworld.com/javaworld/jw-05-1999/jw-05-networked_p.html

Bala
[ June 01, 2005: Message edited by: bparanj ]
 
Stan James
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, this example is a lot of work to override one return type. The technique would pay off a lot bigger if you had a less stable interface or tons of methods to pass through. It might be used to create decorators or links in a chain of command, too. It's rather an "FM function" and a bit cute, but something I'll keep a link to.

FM == Freakin Magic or something like that.
 
That's a very big dog. I think I want to go home now and hug this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic