July 2019
Intermediate to advanced
410 pages
10h 32m
English
An interesting pattern to explore in more detail is the Observer pattern. This pattern allows for instances to be informed of when a particular event happens in another instance. In this way, there are many observers and a single subject. The following diagram illustrates this pattern:

Let's provide an example by creating a simple C# console application that will create a single instance of a Subject class and multiple Observer instances. When a quantity value changes in the Subject class, we want each Observer instance to be notified.
The Subject class contains a private quantity field that is updated by a public UpdateQuantity ...
Read now
Unlock full access