The Artima Developer Community
Sponsored Link

Design Forum
Read/Write interfaces on data object?

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Dan Pollitt

Posts: 1
Nickname: danpollitt
Registered: Feb, 2004

Read/Write interfaces on data object? Posted: Feb 23, 2004 3:46 PM
Reply to this message Reply
Advertisement
Hi,

I have what amounts to a data object but I would like to be able to restrict access to it by revealing this object under different interfaces ("Readable" & "Writable" for simplicity).

I was planning on having my implementation class implement both interfaces and casting between them internally (for example if I am passed a "Writeable" but want to read it I would cast it to "Readable")

This all seemed ok until I was using a mock object framework to mock the implementation of the Writeable to pass in - my casting internally is not supported by the runtime implementation of the interface (produced by dynamic proxy) - this sort of problem usually in my experience points to a design problem.

So, my question is what sort of design change should I consider?

One possible change would be to forget the "Readable" & "Writable" interfaces and combine them into a "DataObject" interface that allows reading and writing?

Any suggestions?

Topic: Lightweight versus Heavyweight Objects Previous Topic   Next Topic Topic: How To Continue With The Code for Sales Program

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use