jeudi 26 juillet 2018

Decorator Pattern (Private vs Protected)

I noticed that most of the examples use protected for the Instance that is being decorated. Could I use private too?

public abstract class CoffeeDecorator implements Coffee {
    protected Coffee decoratedCoffee;

    public CoffeeDecorator(Coffee c) {
        this.decoratedCoffee = c;
    }
    ...
}

Aucun commentaire:

Enregistrer un commentaire