J
Joshua Frank
I've got a design problem that the .net inheritance model will not let me
solve. I didn't like the built in serialization (for various reasons) so I
defined my own serialization approach. I wanted to define an interface
ISerializable, and classes that need serialization would implement this. So
I had a Job class for jobs my app needs to do:
Interface ISerializable
Sub Read()
Sub Write()
End Interface
Class Job
Implements ISerializable
....
End Class
BUT: I then inherited from Job:
Class MySpecificJob
Inherits Job
....
End Class
I wanted to have MySpecificJob implement ISerializable, and when called, it
would serialize itself and then serialize MyBase, but .net doesn't allow
this, saying: "Interface is already implemented by the base class" I think
the framework should clearly let you override the implementation in a
derived class, so that you can use interface based design in a situation
like this.
So then I tried defining a class:
Class Serializable
Sub Read()
Sub Write()
End Interface
Class Job
Inherits Serializable
....
End Class
This works well but breaks when I need to serialize a class that already
inherits from something else, because .net also doesn't let you inherit from
multiple classes.
I kludged around this, but I'd really like to get the right approach. Any
ideas much appreciated. Thanks.
Cheers,
Josh
--
Joshua Frank
Senior Systems Architect
Archimetrics, L.L.C.
"Add some SpArk to your stored procedure development."
(web) http://www.archimetrics.com
(email) mailto:[email protected]
(voice) (973) 727-1510
solve. I didn't like the built in serialization (for various reasons) so I
defined my own serialization approach. I wanted to define an interface
ISerializable, and classes that need serialization would implement this. So
I had a Job class for jobs my app needs to do:
Interface ISerializable
Sub Read()
Sub Write()
End Interface
Class Job
Implements ISerializable
....
End Class
BUT: I then inherited from Job:
Class MySpecificJob
Inherits Job
....
End Class
I wanted to have MySpecificJob implement ISerializable, and when called, it
would serialize itself and then serialize MyBase, but .net doesn't allow
this, saying: "Interface is already implemented by the base class" I think
the framework should clearly let you override the implementation in a
derived class, so that you can use interface based design in a situation
like this.
So then I tried defining a class:
Class Serializable
Sub Read()
Sub Write()
End Interface
Class Job
Inherits Serializable
....
End Class
This works well but breaks when I need to serialize a class that already
inherits from something else, because .net also doesn't let you inherit from
multiple classes.
I kludged around this, but I'd really like to get the right approach. Any
ideas much appreciated. Thanks.
Cheers,
Josh
--
Joshua Frank
Senior Systems Architect
Archimetrics, L.L.C.
"Add some SpArk to your stored procedure development."
(web) http://www.archimetrics.com
(email) mailto:[email protected]
(voice) (973) 727-1510