Observer Nugget Follow-up

For those of you who want to experiment with the Observer Pattern project I demoed at tonight's NxtGenUG meeting, the sample code can be downloaded here (note: this is a Visual Basic Express 2008 project).

If you also want the PowerPoint presentation, it can be downloaded here (note: this is in PowerPoint 2007 format).

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Observer Pattern Nugget

I'm doing a short presentation tomorrow evening at my local NxtGenUG user group meeting on the subject of the Observer Pattern.

I've been doing a lot of reading lately about Design Patterns. Design patterns are recognised solutions to common software development problems and there is a lot more awareness of them in the Microsoft developer community thanks to the efforts of the Microsoft Patterns and Practices team and events such as DDD.

The Observer pattern is one of the simpler design patterns to understand. In a nutshell, it is a mechanism which allows one or more objects (classes) in your program to be notified of changes in state within another object so that they can then update themselves, or take some other action based on the state of the observed object. It is one of my favourite design patterns, because when I discovered it, it was if I was a blind person who could suddenly see again.

You see, about two years ago, I was writing a case management system for the secured loans department within the company I was working for at the time. The application had an MDI-style interface where multiple child forms could be open within a single parent window, each child form displaying some subset of the applicant's details (employment status, outstanding credit, etc.). However, early in the project, I ran into problems trying to keep the information on all the child forms synchronized when the details or status of a case changed. I toyed with several solutions:

  • only allowing one child form to be open at a time
  • writing code in each child form's Activate event to get the latest data from the database
  • putting a "refresh" button on each child form which, when clicked, would get the latest data from the database

None of these options seemed particularly satisfactory, but I didn't know any other way of solving the problem at the time. In the end, I went for the last option, as it seemed the "least bad" of the three.

Now, fast-forward two years: I was reading an article about the Observer pattern in a magazine and as I read, it slowly dawned on me that this was the solution I had been looking for! If only I had known about it sooner, it would have saved me so much time.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

The car in front is…me!

Well, I've finally got rid of my troublesome Peugeot 206 and traded it in for a 3-year old Toyota Yaris.

Yaris exteriorNow, I know the Yaris has a reputation for being a woman's car but I'm not bothered about that. All I want from a car is to get me from A to B reliably, comfortably and economically (especially with petrol prices as they at the moment). So, the Yaris ticks all the boxes and this particular model has a few nice extra touches such as alloy wheels, air conditioning, on-board computer and fancy interior trim, which is rare to find in a small car.

It has a 1.3L engine, so it has a little more poke than the 1.1L of the 206. Having that extra bit of power makes a big difference, especially when you need to overtake a lorry on a hill. Previously, I had to wait until the wind was behind me before I would even attempt such a manoeuvre.

Yaris interiorOne of the more unusual features of the Yaris is  that the speedometer, rev counter and fuel gauge displays are not directly in front of you behind the steering wheel as you would expect, but set into a console which is slightly offset to the left, yet still facing towards you, as shown in the photo. The displays are also sunken into the console, so it feels like you're looking down a periscope. It's strange at first, but you soon get used to it and after a while, it feels completely natural.

Anyway, I love it and I'm looking forward to many years of trouble-free driving in it!

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5