I've had the recent occasion to code something involving TFileStream, and came across a question regarding design.
What I'm doing (more or less) makes it suitable to descend a class from that. The problem is, a lot of the methods of TFileStream are either irrelevant or run completely counter to the function of the code I'm writing. I know I can override methods and get what I want done, and in fact I need to completely replace two of the methods in TFileStream in order to do what I want. The problem is the list of counter-productive methods.
So...I have two options. Option #1: List counter-productive methods in the protected section with overrides and define empty methods.
Or Option #2: Define an instance of TFileStream in my class, create/destroy it in my constructor/deconstructor and then use it.
So the question: Which is the more preferred way to do it?
What I'm doing (more or less) makes it suitable to descend a class from that. The problem is, a lot of the methods of TFileStream are either irrelevant or run completely counter to the function of the code I'm writing. I know I can override methods and get what I want done, and in fact I need to completely replace two of the methods in TFileStream in order to do what I want. The problem is the list of counter-productive methods.
So...I have two options. Option #1: List counter-productive methods in the protected section with overrides and define empty methods.
Code:
TMyClass = class(TFileStream)
...
protected
function Seek(Offset: Longint; Origin: Word): Longint; override;
function TMyClass.Seek(Offset: Longint; Origin: Word): Longint;
begin
end;
Or Option #2: Define an instance of TFileStream in my class, create/destroy it in my constructor/deconstructor and then use it.
Code:
TMyClass = class(TObject)
private
fFileStream: TFileStream;
...
So the question: Which is the more preferred way to do it?