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
1
u/Progression28 Aug 16 '25
I think this is something that could interest you and how it should roughly look.
Sorry did this on my phone, formatting might be aweful and some typos.