Objectives

Students will be able to:

  • implement the Observer design pattern

Object Oriented Programming

Observer Design Pattern

 

Scenario

A system is composed of:

  • a GradeBook object stores a list of student's subjects and grades (GradeData objects).
  • an email notification system that should automatically email a student when grade data is added or updated.
  • a dashboard which is automatically updated when grades are added or updated.

The second 2 items on the above list should be updated automatically when the GradeBook changes.

How can we implement this? One option is to use the Observer design pattern.

Getting Started

Create a new project in your IDE and include these 2 files:

Video Task

Follow the video.

Worksheet Task

Answer the questions in the Worksheet.

Return to the Worksheet.

Glossary

observer

static

class variable

private

data hiding

encapsulation/p>

instance variable