/*******************************************************************************
* Companion code for the book "Introduction to Software Design with Java",
* 2nd edition by Martin P. Robillard.
*
* Copyright (C) 2022 by Martin P. Robillard
*
* This code is licensed under a Creative Commons
* Attribution-NonCommercial-NoDerivatives 4.0 International License.
*
* See http://creativecommons.org/licenses/by-nc-nd/4.0/
*
*******************************************************************************/
package e2.chapter8;
/**
* An object that observes a CardStack. Design with push data flow.
*/
public interface CardStackObserver {
default void pushed(Card pCard) {}
default void popped(Card pCard) {}
default void cleared() {}
}
Chapter 8, insight #10
An abstract observer can define multiple callbacks. Abstract observer interfaces can also be split up in smaller observer interfaces to afford more flexibility in defining how observers can respond to events
Chapter 8, insight #10
An abstract observer can define multiple callbacks. Abstract observer interfaces can also be split up in smaller observer interfaces to afford more flexibility in defining how observers can respond to events
Chapter 8, insight #11
If it is often the case that observers implement callbacks by doing nothing, consider using adapter classes or default methods
Chapter 8, insight #11
If it is often the case that observers implement callbacks by doing nothing, consider using adapter classes or default methods