F
f
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
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