June 2017
Beginner
352 pages
8h 39m
English
Now we'll show how it's quite possible to write nice object-oriented code without needing classes. We have a requirement to produce boarding cards for our passengers in alphabetical order. However, we realize that the Flight class is probably not a good home for details of printing boarding passes. We could go ahead and create a BoardingCardPrinter class, although that is probably overkill. Remember that functions are objects too and are perfectly sufficient for many cases. Don't feel compelled to make classes without good reason.
Rather than have a card printer query all the passenger details from the flight, we'll follow the object-oriented design principle of "Tell! Don't Ask." and have ...
Read now
Unlock full access