April 2019
Intermediate to advanced
360 pages
9h 17m
English
We will demonstrate the null object design pattern with a simple TrainStatus interface that has three methods to activate, deactivate, and check whether the object is currently activated. Five classes will be used, each implementing the TrainStatus interface. The NorthernTrain, EasternTrain, SouthernTrain, and WesternTrain classes will be identical. The NullObjectTrain class will be similar to the other classes in that it will implement the TrainStatus interface, but it will have no functionality. This is illustrated with the UML class diagram in the next section and then again with the source code in an additional section.
Read now
Unlock full access