File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Override Super method, if code unchanged. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Override Super method, if code unchanged." Watch "Override Super method, if code unchanged." New topic
Author

Override Super method, if code unchanged.

Andrew Burger
Greenhorn

Joined: Mar 22, 2007
Posts: 3
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
AnandKumar Palkar
Greenhorn

Joined: Jun 18, 2008
Posts: 2
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.
Ryan Beckett
Ranch Hand

Joined: Feb 22, 2009
Posts: 192




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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Override Super method, if code unchanged.
 
Similar Threads
can't able to compile javabean file
access to superclass's private instance variables
EL Execution Problem
is this correct way of implimenting comparable interface
Creating a bean in session scope