16.4.  Review Questions

[ fromfile: morepatterns-questions.xml id: morepatterns-questions ]

  1. How can a creational pattern help manage object destruction?

      By adding the pointer to a list of objects to be destroyed, before returning it from the Factory method. This can be achieved in a number of ways, such as adding it as a child to another object, or a managed pointer collection.

  2. How can properties help you write a more general-purpose Writer?

      Properties can be inspected at runtime to find out what names/values need to be loaded/saved. This way, you can write one serializer for all QObjects.

  3. How can an Abstract Factory help us write a more general-purpose Reader?

      With an Abstract Factory, we can "plug in" different kinds of ObjectFactory objects into the same Reader, to support different libraries of types. This helps separate the Reader code from the library-specific code.

  4. What Qt classes are implementations of the Facade pattern? Explain why they are facades or wrappers.

      QString, QWidget, QThread, QProcess, QSqlDatabase, QFile, and many others.