Monday, April 24, 2006

I hate the empty constructor


I was looking for inspiration for a short post about the abuse of the parameterless constructor. Then I found this and thought that there’s not so much else to say. If there is still somebody still convinced that

Person p = new Person();
p.setName(“John”);
p.setSurname(“Smith”);

is still as good as

Person p = new Person(“John”,”Smith”);

…please leave a comment.

Ok, then I thought this was a little bit too short, and wrote down some more explanation in the following post.

Tags: ,

1 comment:

Anonymous said...

its ok to call for example Person("Heinz", "Spack", true),

but not beeing used as "classextractor":

Person( "Heinz", myOtherDataObject )
Person(myDataSheet)
Person(myBarcodeTextContainingPersonValues)

thats shit

better use a factory or something similar for this