-
Book Overview & Buying
-
Table Of Contents
Learning Python Design Patterns - Second Edition - Second Edition
By :
We will take up a news agency case to demonstrate the real-world scenario for the Observer pattern. News agencies typically gather news from various locations and publish them to the subscribers. Let's look at the design considerations for this use case.
With information being sent/received in real time, a news agency should be able to publish the news as soon as possible to its subscribers. Additionally, because of the advancements in the technology industry, it's not just the newspapers, but also the subscribers that can be of different types such as an e-mail, mobile, SMS, or voice call. We should also be able to add any other type of subscriber in the future and budgeting for any new technology.
Let's develop an application in Python v3.5 and implement the preceding use case. We will start with the Subject, which is the news publisher:
Subject behavior is represented by the NewsPublisher class
NewsPublisher provides you with an interface so that subscribers...
Change the font size
Change margin width
Change background colour