peter peter - 7 months ago 23
Java Question

How can I efficiently browse through extends and implements in Java?

The idea of polymorphism sounds great on paper. In real life someone joins a new project and starts working on this code:

class Tom extends Cat implements Male {
temperature temperature = Tom.getTemperature();
class Cat extends Feline{
class Feline extends Mammals{
class Mammals extends Animals implements WarmBlooded{
class WarmBlooded{
int temperature=96; //In case they forget to set the right temperature...
public int getTemperature(){
return temperature;

Compare to

Cat cat = new Cat(Tom, m, 96);


class Cat(Stiing name, char gender, int temperature){

Sure, we saved a couple of lines of code by implementing
, but at what cost? We have to look through multiple classes just to find out what
is doing - isn't this an example of a spaghetti code? Millions of coders chose Java. There must be a reason for polymorphism. I will anyway have to keep in mind name, gender and temperature of a cat I am creating. Implementing
is no different than passing "m" as a parameter when creating Tom. Why not bundle everything in

Does it mean I should read and understand the whole project to start benefiting from polymorphism? Are there any methods to make browsing through extends/implements easier?

removed "abstract".

What does efficiently browse through extends/implements mean?

It means "can find out what this method is doing in reasonable time".


Use IDE. Such as NetBeans or Eclipse. Also, use UML. Otherwise it is hard to follow the code. It allows you to click on getTemperature() to see the implementation.

 Class Feline is useless if it only holds   
    Boolean isFeline = true;

However, if it holds multiple methods it makes life easier - you don't have to keep in mind all these methods.

Java works best for larger projects. Joining such projects can be more difficult.