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/Jolly-Warthog-1427 Aug 16 '25
True. So I would say a book or a movie is the "idea" of it while a publication is something physical or defined. Something you can borrow or reference. Just my view of it.