I have a custom collection Doohickeys
indexed by keys. This collection has a factory method createDoohickey(key)
and an accessor Doohickey(key)
. Should createDoohickey(key)
return the new object or should it return void
?
In the first case, I would use it like this
myDoohickey = doohickeys.createDoohickey(key);
doStuff(myDoohickey);
in the other case like this
doohickeys.createDoohickey(key);
doStuff(doohickeys(key));
Which one would you consider preferable, and why?