I have several classes
Child9 implemented in Java.
Parent is an abstract class, containing all the common variables of the child classes (a lot, which is the main reason why I made
Parent an abstract class and not an interface), some abstract and some implemented methods.
Some of the child classes have custom methods which are specific to them. So often I find myself calling a child method using downcasting:
Parent p = new Child1(); ((Child1) p).child1SpecificMethod();
Somehow I have the feeling that this is bad OOD practice, but I am not quite sure if that really is the case respectively how to improve the design.
- Edit - What I probably should change anyway is the fact that I use the Parent class for organizing many (for now) common variables, making them (or a container object) members of the concrete classes.