Forums Register Login

Override Super method, if code unchanged.

+Pie Number of slices to send: Send
I was wonder is it best practice to override methods that a super class has already has defined in enterprise applications. And how about if or should Husky implements Dog(Interface) with setName and getName?

Example.
Dog Class

Husky Class


And
+Pie Number of slices to send: Send
Methods of the super class should be overridden in a sub-class only when they are required to do a different thing.

In your example, there's no need to override getName() and setName() in Husky.
+Pie Number of slices to send: Send




Here, Husky still behaves the same as Dog and it inherits getName and setName already, so there's no need to override those methods. That's redundant, the exact opposite of what polymorphism promotes. There's no need to implement those methods.
If you have a bad day in October, have a slice of banana cream pie. And this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1453 times.
Similar Threads
can't able to compile javabean file
EL Execution Problem
access to superclass's private instance variables
Creating a bean in session scope
is this correct way of implimenting comparable interface
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 19, 2024 05:08:21.