Derived data and process, a pattern?

From: f (ffunus_at_yahoo.com)
Date: 11/30/03


Date: 30 Nov 2003 09:08:17 -0800

The problem is this:

I have different data type, say data1, data2, each one has a special
way for I/O.

class Data1{...}
interface IO1 {
    Data1 load();
    void save(Data1 data);
}

class Data2{...}
interface IO2{
    Data2 load();
    void save(Data2 data);
}

However, I want to orgnize them in a uniform way, So I set up a frame
work, say:

class Data{...}
interface IO{
    Data load();
    void save(Data data);
}

I derive data1, data2, ... from Data.
I derive IO1, IO2 from IO.

But I want IO1 works only on data1, IO2 works only on Data2...

Thus,

class Data1 extends Data{...}
interface IO1 extends IO {
    Data1 load();
    void save(Data1 data);
}

class Data2 extends Data{...}
interface IO2 extends IO {
    Data2 load();
    void save(Data2 data);
}

I want in the derived interface "load" and "save" replace the same
method in IO, but with different data type. But looks like this does
not compile. How can I fix it?

Should this be a pattern? Each Process works on a Special data, but
global, they still follow some interface so they can be treated the
same way if nessary.

Thanks,

ff



Relevant Pages

  • derived data and process, a pattern?
    ... I have different data type, say data1, data2, each one has a special ... Data1 load(); ... void save; ... interface IO2{ ...
    (comp.lang.java.help)
  • derived data and process, a pattern?
    ... I have different data type, say data1, data2, each one has a special ... Data1 load(); ... void save; ... interface IO2{ ...
    (comp.lang.java.databases)
  • Problem getting events from C# to VJ++
    ... interface IWeatherEvents: IUnknown ... public delegate void WeatherChangedDelegate(int nTemperature); ... // float Temperature ... private float m_fTemperature = 0; ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Question about Java updates installed?
    ... public long add(int a, int b) ... either encapsulate the add method in an interface and then ... void test() throws Exception { ... A multicast delegate was also possible. ...
    (comp.lang.java.advocacy)
  • Re: Ribbon and a checkbox (C++ ATL)
    ... public void Ribbon_onAction ... When I do a C# addin that has to support Outlook 2003 and later I use ribbon interface definitions based on a blog article by Andrew Whitechapel of the VSTO team in a RibbonInterop class and handle the callbacks in a RibbonX class. ... MethodCodeType = MethodCodeType.Runtime), DispId] get;} ... string Tag { ...
    (microsoft.public.outlook.program_addins)