Re: Constructor call constructor
- From: "Bruce Wood" <brucewood@xxxxxxxxxx>
- Date: 4 Apr 2006 09:47:56 -0700
Geoffrey wrote:
Personnaly, I choose to place all the code in the constructor with all the parameters.
The constructors with minder parameters are only "shortcuts" for the full constructor
I agree. I have tried both ways and I find it much clearer putting all
of the code in the constructor with the most parameters and then
setting up the other constructors as "shortcuts" to it.
The only problem comes when you introduce inheritance where the child
class also has the same "shortcut" scheme. It's a toss-up as to whether
the child class should do the same as the parent, duplicating the
default values for the optional arguments, or call the parent's
"shortcut" constructors, thus duplicating the code that initializes
fields in the child.
I still haven't figured out a clean way to handle that one. Any takers?
.
- References:
- Constructor call constructor
- From: Geoffrey
- Re: Constructor call constructor
- From: amaca
- Re: Constructor call constructor
- From: Ignacio Machin \( .NET/ C# MVP \)
- Re: Constructor call constructor
- From: Geoffrey
- Constructor call constructor
- Prev by Date: Re: win32security
- Next by Date: Re: System.Net.Sockets.Socket threw an exception
- Previous by thread: Re: Constructor call constructor
- Next by thread: Re: Constructor call constructor
- Index(es):
Relevant Pages
|