Overloaded constructors - safer, easier structure?
From: Martin James (mjames_falcon_at_dial.pipex.com)
Date: 11/29/03
- Next message: valentin tihomirov: "it was a response to Martin James"
- Previous message: valentin tihomirov: "Re: Understanding threading"
- Next in thread: Joanna Carter \(TeamB\): "Re: Overloaded constructors - safer, easier structure?"
- Reply: Joanna Carter \(TeamB\): "Re: Overloaded constructors - safer, easier structure?"
- Reply: Wayne Niddery [TeamB]: "Re: Overloaded constructors - safer, easier structure?"
- Reply: Martin James: "Re: Overloaded constructors - safer, easier structure?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 29 Nov 2003 15:02:53 -0000
I've got these overloaded constructors:
**********************************
constructor TmyClass.create(someParams);
begin
beforeStuffDependsOnSomeParams;
otherBeforeStuff;
inherited create(params);
afterStuff;
end;
constructor TmyClass.create(otherParams);
begin
beforeStuffDependsOnOtherParams;
otherBeforeStuff;
inherited create(params);
afterStuff;
end;
**********************************
Can I somehow put all the common code into a procedure/function?
**********************************
function TmyClass.initialize:TmyClass;
begin
otherBeforeStuff;
result:=inherited create(params);
afterStuff;
end;
constructor TmyClass.create(someParams);
begin
beforeStuffDependsOnSomeParams;
self:=initialise;
end;
constructor TmyClass.create(otherParams);
begin
beforeStuffDependsOnOtherParams;
self:=initialise;
end;
**********************************
OR in some other way put all my common code in one place so that when I
create more objects that always need to be there I don't forget to include
the code in one of the constructors?
Rgds,
Martin
- Next message: valentin tihomirov: "it was a response to Martin James"
- Previous message: valentin tihomirov: "Re: Understanding threading"
- Next in thread: Joanna Carter \(TeamB\): "Re: Overloaded constructors - safer, easier structure?"
- Reply: Joanna Carter \(TeamB\): "Re: Overloaded constructors - safer, easier structure?"
- Reply: Wayne Niddery [TeamB]: "Re: Overloaded constructors - safer, easier structure?"
- Reply: Martin James: "Re: Overloaded constructors - safer, easier structure?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|