R
Robert Zurer
Hello All,
Is it considered a best practice to always write a parameterless constructor
for any object - just in case?
I'm not sure. I want my object to have all it absolutely requires to function
in the world at birth. Defining a parameterless constructor allows it to be
created in an unstable state.
On the other hand
1. XmlSerializer doesn't like objects without one. Web Services have a problem
with this
2. The generic new() constraint takes no parameters
3. It's kind of handy to be able to just call Activator.CreateInstance with
just a Type. (Dependency Injection is easier simply assigning properties after
the fact.)
Any other pros or cons??
Thanks
Robert Zurer
Is it considered a best practice to always write a parameterless constructor
for any object - just in case?
I'm not sure. I want my object to have all it absolutely requires to function
in the world at birth. Defining a parameterless constructor allows it to be
created in an unstable state.
On the other hand
1. XmlSerializer doesn't like objects without one. Web Services have a problem
with this
2. The generic new() constraint takes no parameters
3. It's kind of handy to be able to just call Activator.CreateInstance with
just a Type. (Dependency Injection is easier simply assigning properties after
the fact.)
Any other pros or cons??
Thanks
Robert Zurer