Objects in my open-source toolkit are all based on the class AbstractObject. I want to add a function into AbstractObject which will create and return object of the exact same class.
This is different from cloning, because the property values are not copied. I thought about calling it duplicate but it is confusing when working with ActiveRecord classes (as duplicate would be used to duplicate record, not object).
form2 = form1->createObjectWithSameClass()
Please suggest a single-word (preferably) name for this. I appreciate your time!
Based on the information here, this sounds like you want another plain object of the same type as a variable in scope, and that type is the only context needed when creating the object.
In that case, this sounds like a valid case for a Factory instead of a method hanging off of an instance. You could do, perhaps:
myFactory.create(form1)or
EDIT: this is not a direct answer to your question, but because you are concerned with naming, and therefore I assume with clarity of code, one of the big benefits of a pattern is clarity (everyone knows what a Factory is, so they won’t be confused by whatever name you end up choosing).