(WCF) interface pattern

P

phancey

hi,

I have a requirement to show "History" of various business objects.
From my aspx page, I call WCF services to access the business objects.
If each business object had its own service I would create an
interface IHistory which has a GetHistory method and make each
required service implement this method. Then I could code the front
end more easily getting the relevant service, casting it to the
interface and calling GetHistory.

However, there are already several business objects within the same
service. I am trying to figure out if there is a way I can use a
generic interface i.e. GetHistory<T> which can be implemented
similarly? I have been using generics and interfaces for a while but
am not an expert who can just figure these things out straightaway. I
can't see the pattern I need to adopt in this case (if there is one).
Can I make the service implement IHistory<Account>, IHistory<Order>
etc and use polymorphism easily or am I better to just code for
GetAccountHistory, GetOrderHistory etc but in this case there will
then be lots of if statements checking first which service needs using
and then which method.

Just need some help from someone a bit more expert at these patterns.

TIA
Phil
 
S

sloan

Is your client "DotNet ONLY" ? Or are you serving up wcf to other clients
(asp, java, etc)?

If your in a DotNet to DotNet world only, you can ~try~ to do what you want,
start with this example:
http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!158.entry

If not, then the answer is No, because java/asp/others have no idea what a
Generic is.


With WCF you're going to LOSE some of your OO stuff (the one I've coded
around personally is overloaded method)..........
But (maybe, I don't know) the DotNet-to-DotNet starter code above might get
you to where you want to go.
 
P

phancey

Is your client "DotNet ONLY" ?  Or are you serving up wcf to other clients
(asp, java, etc)?

If your in a DotNet to DotNet world only, you can ~try~ to do what you want,
start with this example:http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!158.entry

If not, then the answer is No, because java/asp/others have no idea what a
Generic is.

With WCF you're going to LOSE some of your OO stuff (the one I've coded
around personally is overloaded method)..........
But (maybe, I don't know) the DotNet-to-DotNet starter code above might get
you to where you want to go.










- Show quoted text -

thanks sloan, I will check your solution later as I can't access it
from work.
 
P

phancey

I'm going to push back on your business requirement here. Services are
essentially stateless. History is not, it implies context. You could easily
shoot yourself in the foot by this approach. How are you implementing this?
A reference to an object that is the history? Perhaps that object is the top
of a deep tree, what then? Are you going to place limit on the history? You
go across the wire with a tree or a graph? You aren't talking about url
links, your are talking about objects that form a history tree. How do you
purge the history? Does it grow unbounded? Every piece of that history has
to be serialized and pushed across the wire. Think about it.

--
Regards,
Alvin Bruney

Want a free copy of VS 2008 w/ MSDN premium subscription?
Details athttp://msmvps.com/blogs/alvin/Default.aspx

Auther Plug
OWC Blackbook now on download atwww.lulu.com/owc










- Show quoted text -

hi Alvin,

unfortunately I don't write the specs, I just implement the
requirement. Basically all I am doing is returning a list of history
objects for a specific Id, each history object being quite small
containing things like UpdatedDate, OldValue, NewValue. There is not
expected to be huge amounts of history for any object as updates are
not frequent.

However I may have missed your point as I'm not entirely sure I got
it. History in the database could grow unbounded - that is someone
else's responsibility to manage that. All I want to be able to do is
to read whatever is there, for object X.

cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top