• 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

Is my example still conform with the Proxy Pattern?

 
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

please view the example from my SCJD assignment. It shows a part from my modeled data and network layer:



We were given the DB interface in the assignment and are not allowed to touch it. For the data layer model I simply used the Adapter Pattern.

To provide network functionality I've chosen to use the Proxy Pattern for the network layer model.

Actually the application runs fine and I am days away to submit the assignment back to Sun.

But now I've some doubts whether my network layer is still conform to the Proxy Pattern.

In terms of Proxy Pattern I distinguish between:

  • RemoteDB - as the Subject interface
  • RemoteData - as the Proxy object
  • Data - as the RealSubject object
  • DB - also as the Subject interface


  • I liked not to have the RemoteDB interface but simply use DB as Subject interface. But due to my constraint from Sun not to touch DB I had to create an identical new interface RemoteDB with same signature like DB but with RemoteException added to all methods.

    Now I have two Subject interfaces and doubt whether I can still call it Proxy Pattern.

    Any feedback from you is welcome .

    Regards,
    Darya
     
    ranger
    Posts: 17347
    11
    Mac IntelliJ IDE Spring
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Moving this to the SCJD forum.

    Mark
     
    author and jackaroo
    Posts: 12200
    280
    Mac IntelliJ IDE Firefox Browser Oracle C++ Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Darya,

    If we take a look at the GOF definition for the intention of the Proxy pattern: "Provide a surrogate or placeholder for another object to control access to it."

    You are providing a surrogate to the Data class, but I don't think you are doing it to control access. The only reason for having your RemoteData class is because your DB interface does not throw the exceptions you want to throw, so you have created RemoteDB and RemoteData to adapt one interface to another.

    Regards, Andrew
     
    Darya Akbari
    Ranch Hand
    Posts: 1855
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Andrew,

    I absolutely agree with you that I have an implementation of the Adapter Pattern but what runs me crazy is the fact that I think as soon as one use RMI she/he uses the Remote Proxy Pattern. And I use RMI to realize the network layer.

    So where is my Proxy Pattern

    ... hold on one second , I think I found where the Proxy Pattern is hidden.

    The real Proxy is my RemoteData_Stub class I got when I run rmic, isn't it? Hence my RemoteData must be the RealSubject objcet and my RemoteDB the Subject interface.

    And the Proxy Pattern diagram for my model looks like:


    To sum up, in my network model I have obviously implemented an Adapter Pattern AND somewhat hidden a Proxy Pattern.

    Andrew, thanks for waking me up

    Regards,
    Darya
     
    Andrew Monkhouse
    author and jackaroo
    Posts: 12200
    280
    Mac IntelliJ IDE Firefox Browser Oracle C++ Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Darya

    The real Proxy is my RemoteData_Stub class I got when I run rmic, isn't it? Hence my RemoteData must be the RealSubject objcet and my RemoteDB the Subject interface.

    Yep, you got it.

    Regards, Andrew
    [ June 11, 2005: Message edited by: Andrew Monkhouse ]
     
    Darya Akbari
    Ranch Hand
    Posts: 1855
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks Andrew

    Regards,
    Darya
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    reply
      Bookmark Topic Watch Topic
    • New Topic