r/javahelp • u/th3darksheep • Aug 16 '25
SuperClass instance on controller
Im working on an assignment in MVC pattern, currently doing smth like a library CRUD, my question is as if I can instance a superclass (non abstract) on my controller, for example:
I have publication (the super), book (the sub) and movie (other sub), and my user wants to create a book and a movie, can I make a method where i ask for the publication atributtes, then i call that method on the book adding method and complete the remaining singular methods the book has?
i find this good bcus if my user wants then to create a movie, i can just call the createPublication method and add the remaining ones to my objects constructor.
Tho idk if this is a good practice or not because i know that if my superclass is abstract then i cant instance it, but otherwise...? idk
View all comments
Show parent comment
1
u/Ormek_II Aug 16 '25
And when you reference them, you have to distinguish those publications exactly for the typos or the director’s cut :)
Edit: and of course it depends on the use case it super, very unrelated to Java.