From 73fe10e134af99c6372425fff69a240ff83596f7 Mon Sep 17 00:00:00 2001 From: Deepak Mishra Date: Sat, 23 Sep 2023 23:07:13 +0530 Subject: [PATCH] Update 08-observer-strategy.md Removed "class" keyword from Observable interface --- notes/08-observer-strategy.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/notes/08-observer-strategy.md b/notes/08-observer-strategy.md index bae7c1e..1f49c00 100644 --- a/notes/08-observer-strategy.md +++ b/notes/08-observer-strategy.md @@ -90,7 +90,7 @@ The two approaches we have discussed so far are not ideal. The first approach vi 1. `Observable interface` - This interface defines the methods that the subject class must implement. The subject class is responsible for notifying the observers when the state of the subject changes. ```java -public interface class Observable { +public interface Observable { void addObserver(Observer observer); void removeObserver(Observer observer); void notifyObservers(); @@ -100,7 +100,7 @@ public interface class Observable { 2. `Observer interface` - This interface defines the methods that the observer class must implement. The observer class is responsible for updating itself when the state of the subject changes. ```java -public interface class Observer { +public interface Observer { void notify(); } ``` @@ -279,4 +279,4 @@ To create a strategy object we can also use a factory method. * Implementing it in place violates the open-closed principle and makes the code harder to maintain. * Inheritance is static, and we cannot change the behavior of the system at runtime. * To use the strategy pattern we create a strategy interface and a set of classes that implement it. -* The context class maintains a reference to a strategy object and delegates the work to it. \ No newline at end of file +* The context class maintains a reference to a strategy object and delegates the work to it.