Some thoughts about `new` function


#1

Let’s consider my class implements Default. Should I make new() function?


#2

Yes, if that’s a common and useful way to use your type. Convention is to have a new method (with or without parameters).

If there is no single dominant way to create the type, maybe only specific named construction static methods is better.


#3

I implement Default, which delegates to new(). I think that new() is extra.


#4

It’s your choice, but it’s not uncommon to have new even if you implement Default.


#5

Unless your type is zero-sized, there’s probably some setters that your users are going to want to call right after creating it. Make those arguments to new.


#6

There is no setters, which can be placed into new.