Developing Connected Applications aligned with Observer Design Pattern


In this post, I will briefly explain Observer design pattern, its use cases and implementations for enterprise, Phone, and Windows store platforms.

Observer, introduced in the book named ‘Design Patterns: Elements of Reusable Object-Oriented Software’ by Gang of Four, is a behavioral design pattern that provides a loosely coupled messaging to one or many subscribers of a subject. It is also called Publish/Subscribe or Pub/Sub or PubSub, (no PS, taken alreadySmile). Think about, a news feed (subject) and its readers (subscribers), when a new feed published (publisher), readers are notified automatically. Its advantages mainly:

  • De-coupled solution: Subscriber no need to know publisher nor be online.
  • Optimized number of call stack: The notifying/updating happens only if there is an update/event that clients (subscribers) are interested. Real-time messaging. Optimized use of resources (less use of network bandwidth, CPU, I/O on both client and server side)
  • 1-M relationship between publisher and subscriber.

This differs from request-response pattern as, by using the feed example above, a reader sends requests periodically (interval can vary – one second, minute, hour, day, etc. depending on the nature of the system) to news feeder service and the service responds back with a new feed if exist (or something else if no update) in a 1-1 relation.


Here are some of the APIs aligned with observer pattern that you can leverage in your solutions:

Windows Notification Service (WNS)

It is a push notification service used for disseminating tile updates (live tiles), toast, badge, and raw notifications to Windows (8.0+) clients. For further details please visit here

Microsoft Push Notification Service

Very much like WNS, but targets Windows phones (7.1+). For further details, please visit here

For both WNS and MPNS, you can leverage Windows Azure Mobile Services (SaaS – Software as a Service) for sending notifications down to clients or you can use your own service publisher. Azure mobile services also serve other phone platforms iOS, Android, etc. Here is a diagram that shows steps for sending notifications from the publisher that is on premise (not Windows Azure mobile service) to Windows store and phone clients. (PCS: Platform Client Service,  NPC: Notification Platform Client) 


Figure #1: Conceptual Architecture for WNS and MPNS


It is really a great API for real-time web messaging. I am not going to repeat my self here. I have a post on this subject, please visit here – Use of SignalR for Real-Time Messaging on Windows RT Devices. It has now version 2.0 and back to site here

Service Bus

    • Windows Azure Service Bus: A cloud service by Microsoft for providing connectivity, queuing and routing capabilities for your needs. For further details, please visit here
    • Service Bus for Windows Server: It is very like Windows Azure Service Bus, but differs as being hosted on your own data center.


Figure #2: PubSub Conceptual Architecture of Service Bus for Windows Server 


This post introduced Observer pattern which is one of the well known and commonly used design patterns in software engineering and its implementations in respect to Microsoft platforms (Windows Phone, Windows tablets/laptops and desktops). Those are WNS, MPNS, SignalR, Windows Azure Service Bus, and Service Bus for Windows server. Please note there might be other MS technologies, I have listed those that I have worked on only. Happy observingSmile