I have a class which implements an interface and have responsibility to create item and "maintain" collection of created items.
Class have method GetOrCreate(int id)
which return instance of created item.
public class PoolOfItems : IPoolOfItems
{
public Item GetOrCreate(int id) { }
}
Requirements for GetOrCreate
method that in case when item, for given id
, is already created, we need provide already created instance.
What is the most "understandable" name for method GetOrCreate
can be used?
I afraid that name GetOrCreate
describes implementation of the interface. And Get
and Create
names can be misleading when used with implementation.
design pattern
question can be "opinion-based" because you can use "Factory" or "Builder" patternIPoolOfItems
can create new instance ofItem
on every call. In this case nameGetOrCreate
is misleading