Workshop

Quiz

1: We did not want our Command::execute() method to be overridden by code in child classes. How did we enforce this?
2: Briefly, how did we ensure that there was only one DataStore object in our system at any one time?
3: We said that the practice of a method calling and using abstract methods defined in the same class was an example of a design pattern. What was its name?
4: Which keyword did we use to check that an object we had instantiated belonged to the Command family?
5: How did we ensure that our Command class status flags were unchangeable and available via the class rather than particular object instances?

Answers

A1: You can prevent a child class from overriding a method by declaring it final.
A2: We made the

Get Sams Teach Yourself PHP in 24 Hours, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.