Some programmers avoid "new" as a constructor name.
What are some examples of how this can improve code?
- iterator := Iterator traversing: anArray.
-
- This one's not bad, though some would still consider naming it "newTraversing" to make it a bit more consistent.
What are some examples of how this can worsen code?
- user := User instantiate: 214.
-
- Why throw away the existing habits of object-oriented programmers if you don't get any clear benefit? I've heard it argued that you're not creating a "new" user, only "instantiating" one. However, in this case, the one-line description of the "User" class would be something like, "Represents a user of the system". So, you actually are creating a "new" representation of a user of the system.
See also FactoryMethodPattern, NamedConstructor