Is there a Design pattern which returns me child or parent class based on condition.
The scenario is:
I have a basic class and a complex class which extends the basic class. What I need is as per user requirement I return basic or complex class. I was able to implement is using basic if else condition but feels that this doesn't seem right logic. There must be a proper way of doing this given a scenario that my classes can have structure like this
public class SimpleClass {}
public class ComplexClass extends SimpleClass {}
public class MoreComplexClass extends ComplexClass {}
and goes on ......
If my question is wrong and if I should be changing the way I'm creating the classes. Please guide.