Caution about how inherited classes are presented in topic 1 of OOP


Your topic 1 of intro to OOP presents a class as a derived class of This is extremely bad example to use for beginners and does not give a correct representation of true OOP subclass derivation.
You should only ever use public static void to make use of already defined classes.


Could you explain that a little more?

I honestly think that Mouse being a subclass of Rodentia is a very good example. Like "Carrera" being a subclass of "PorscheCarModels"

I don't understand your last statement about the public static void thingy...

(No offence intended, just here to learn and help)


There is no problem with mouse being a subclass of rodentia. The problem is that with using console for I/O AND starting to learn about building classes, its too easy and lazy to lump everything into one main class. If I was teaching someone on class building, I would recommend keeping public static void in a separate class.
It's ok for small compact programs where you only want to test java code.
When you get into complex classes, keeping them in their own classes makes the code elegant.
I would say, have a separate class for your public static void I/O, for example, rodentiaDisplay class. So you have your main rodentia class, your derived mouse class, and you rodentiaDisplay class.
You're welcome to disagree. This is a personal thing.

Well, let me clarify further. I learned to do it this way in Uni. The instructor was pedantic about writing good structured code, so its not a "personal thing". You can read any number of text books on Java and discover any number of ways to write code. Get the best and discard the rest.


Agreed. Our teacher also gave us drills, just on the way we wrote code.
I understand what you mean now, I just misinterpreted your words. My bad :smile:

But yes, you're absolutely right, understanding inheritance of classes is important, but understanding WHY there is such a thing, is even more important (at least that's my opinion). Because looking at some programs, there is WAY too much duplicated code. (Whether you use an interface for your methods or a superclass for everything, it's still better to avoid duplicated code).


I have'nt found an intelligent parser yet in Netbeans that will address this issue completely. It comes down to code review in the end.
Very interesting point for discussion.
I found something similar the other day in a forum on how optimizing compilers have almost disappeared from use due to the fact that we now have far greater memory space in computers.
I think the two are very close. I wonder whether deep learning will produce such an item.