Yesterday I taught my Advanced Java Class from 5:00PM to 8:00PM. In the previous class we started looking at the Observer Design Pattern with a very brief introduction and a look at some code from an example, which I later found may be a bit too complex for the students. For this Java class, I decided to use a very simple example to demonstrate Java’s Observable class and Observer Interface which I hoped would help make the concepts easier for the students to grasp. However, I found the look on their faces to indicate that there was still some level of confusion with respect to the topic. I had to figure out some way to relate this topic to a way they can understand. Then I thought of social media and status updates. I decided to use notepad.cc to share the instructions with them as I had to think of the exercise off the top of my head. I asked them to create a MyStatus class as a subclass of Java’s Observable class, then create two private Strings called mystatus and profilename. Also create a constructor for MyStatus that sets the profilename when an instance is created. In this “MyStatus” Class, a method called statusChanged(String newStatus) was also added, which was called to change the status of a user by passing in the new status as a parameter. This statusChanged(String newStatus) method will also call setChanged as well as notifyObservers as part of its implementation. Then the students implemented the Observer interface and called that class ProfileFriend, created a private variable in the ProfileFriend class called “profilename” as well as a constructor for ProfileFriend that sets profilename when an instance is created. In the ProfileFriend Class, they implemented the update method printing out to the console every time the status was updated. In the main class an instance of MyStatus was created as follows : MyStatus myProfile = new MyStatus(“Nekelle”), using their name, then an array of observers was created with each observer in the array representing a member in our class at the University. The observers were then added to the Observable class using an advanced for loop which luckily for the students they had never seen, so this gave me the opportunity to explain it to them and teach them a different way to approach a for loop. Finally the statusChanged method was called on the instance of MyStatus and changed to “I love Java”. This approach really helped the students grasp the concept as they could relate it to facebook. The initial example with stock prices seemed so foreign to them and I’m glad I was able to think of this at the last moment. Next class, I’m hoping to mainly work on exercise tutorials and finish up the Observable class and Observers. There are currently 3 more modules to complete in this Advanced Java course and I would like very much to make sure all of the students grasp all the concepts covered so far before we move on.