Nick Hodges is running a nice series of design pattern articles these days. They are based on the Java examples in the “Head First Design Pattern” book.
These examples are of course easy to replicate in Smart Mobile Studio.
There are a few difference between the Delphi and Smart Pascal languages, but it’s mostly cut’n’paste and minor resolvents to have the examples running under Smart.
The Smart version of this code can be downloaded from http://smartmobilestudio.com/SmartCode/HFDP/Observer.opp.
We had to add an additional TWeatherDataDisplay class to the original example, of course…
TSmileyDisplay = class(TForecastDisplay)
procedure Display; override;
This is what you get:
(Can also be executed directly from http://www.smartmobilestudio.com/smartdemo/HFDP/Observer/)