Newbie Modelling Interface Question

From: AdamJoe (adamjoe1_at_yahoo.co.uk)
Date: 10/25/03


Date: Sat, 25 Oct 2003 20:08:48 +0100

Hi all,
I'm fairly new to this game so please bear that in mind when posting a
reply. I'm trying to figure out the best way to model the following problem.

I have an architecture made up of a number of subsystems, one of which is a
Hardware Interface subsystem. A client's access to this subsystem is
restricted to the interfaces it realises. The client will hold a pointer(s)
to the abstract type of the interface(s) and use it to invoke the
appropriate methods on the derived class(es).Inside this subsystem I have
two classes, amongst others, Fram and Rom, which implement the following
methods.

Fram
Read
Write
CrcCheck

Rom
CrcCheck

It is anticipated in the future that there will be other memory types. I
would like to define an interface or interfaces for this subsystem that
these classes can derive from and clients can depend on.

One option I've considered is to have two interfaces. The first is IMemory,
which Rom derives from and provides one pure virtual function, CrcCheck. The
second is IRWMemory which Fram derives from and provides pv functions Read,
Write, and CrcCheck. The client then has a pointer to each interface.

Another option is to have two interfaces again but one derives from the
other. IRWMemory would derive from IMemory and inherit its CrcCheck
operation. Rom would derive from IMemory and Fram from IRWMemory. Again the
client would have a pointer to each interface.

A third option is to have one interface that supports all the methods and
both Rom and Fram would derive from it. In Rom's case, it would have to
generate an exception or whatever was appropriate if the client tried to
invoke a Read or Write operation on it. This seems to me to be the least
elegant of the three and if I implemented it this way there wouldn't be much
point in the interface as not all derived classes would be able to implement
the operations it supports.

Make sense?

I'm not sure how good or bad these solutions are. I can't find anything that
helps in any books or on any of these newsgroups. I'm looking for feedback
on what is wrong or right with this approach and any other potential options
that I've not considered would be appreciated.

Thanks in advance,

Adam.



Relevant Pages

  • Re: Newbie Modelling Interface Question
    ... > Hardware Interface subsystem. ... > two classes, amongst others, Fram and Rom, which implement the following ... > CrcCheck ... > second is IRWMemory which Fram derives from and provides pv functions Read, ...
    (comp.object)
  • Re: Remoting Objects: style question
    ... Most likely, if you use abstract objects, the first cast will be done in the ... class to which it is cast, regardless of whether it derives from that class. ... acobj will be non-null even though the remoted object is ... > the object actually implements the interface). ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: 1800 Router Internet not working after power failure
    ... ROM: System Bootstrap, Version 1 ... Provenir uptime is 2 hours, ... Serial interface ... input packets with dribble condition detected ...
    (comp.dcom.sys.cisco)
  • RE: Implementing custom interfaces
    ... When you added a web reference to your project, ... that derives from SoapHttpClientProtocol. ... implemented in this file will not have derived from your interface even if ... I have created a web service which implements a custom interface. ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • RE: Implementing custom interfaces
    ... that derives from SoapHttpClientProtocol. ... implemented in this file will not have derived from your interface even if ... I have created a web service which implements a custom interface. ...
    (microsoft.public.dotnet.framework.aspnet.webservices)