I have a function which takes an object parameter say entity and returns concrete objects like below. The concrete objects inherits from IEntity.
public IEntity GetEntity(object entity)
{
if(entity is A) { .... return new Customer(); }
else if(entity is B) {... return new Invoice(); }
.......
}
This obviously works but I was wondering if this is the best approach or is there any other alternative and recommended way from architecture perspective?
Thanks!