vendredi 22 janvier 2021

Defining attributes in abstract methods is good or bad

Is it a good design to define attributes in abstract class and use it like below. For example

class Base {
    @Getter
    private String name;

    protected Base(String name) {
        this.name=name;
    }
}



class Derived extends Base {
    public Derived() {
        super("name");
    }
}

Should I put attribute name is inside base class or should I put it in the derived class. Which one is a good design and how to decide that.

Aucun commentaire:

Enregistrer un commentaire