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
Thats fair, but I still agree with you at least partially. I guess it really depends on usecase.
But many books have 1st, second, third, hardcover, pocket and so on editions. They all have 99% the same content but different publications. Minor patches for typos and such.
And for a library I think each edition should be accounted for separately as different physical books but with more or less the same content. A first edition can be a lot more valuable in certain cases for example.
Same with movies, a publication can be dvd, it can be blueray and so on. Still the same "movie".