UNISA Chatter – Design patterns in C++ Part 3: Generics & Serializer Pattern

See UNISA – Summary of 2010 Posts for a list of related UNISA posts. Continued from UNISA Chatter – UNISA Chatter – Design patterns in C++ Part 2: Composite Pattern.

QT and Environment Summary

The following is a summary of findings as I worked through the course related book. See the summary post for details on the book.

Terminology Description Example
Function Parameter A function parameter can pass values and variables foo (int x)
Template Parameter A template parameter can pass values, variables and type expressions. template <class T, int max ) foo
Template Function instantiation When the compiler stumbles across a template function for the first time with specific parameter type(s), the template is instantiated. Subsequent calls are translated into normal function calls.  
Template Header File To allow the compiler to generate code from a template declaration, we typically place the template definitions in header files.  
QT Containers (QTC) QT Containersare classes that collect value types that can be copied. QObject and types derived from QObject cannot be assigned as they cannot be copied. QMap, QMultiMap, QHash, QCache
QTC Key to value mapping Containers that identify data with a key value pair, a known as key to value mapping type containers.  
Managed Container A managed container uses containment (solid diamond … see airport UML diagram in part 2 post) and is responsible for the management, storage and destruction of objects it owns.  
Unmanaged Container An unmanaged container uses aggregation (empty diamond) and typically does not contain objects, but delivers indexing and referencing navigation mechanisms.  

Design Pattern Summary

Terminology Description
Pattern: Serializer
  • Behavioural design pattern
  • A serializer object is only responsible for reading and writing objects, which encapsulates the read/write logic , therefore making it easier to change the object format and promoting maintainability.
  • An example is the QDataStream class, which allows serialization and deserialization of all QVariant supported types, such as QList, QMap, QVector, etc.

The illustration shows the use of serializers to decouple the reading from and writing to files from the data objects. The great advantage of the serializer pattern is that we can replace or change the reading and writing behaviour, without touching the data objects.


I had lots of fun writing the code and debugging the gremlins and odd behaviours using the QT IDE … again, I really miss the Visual Studio Debugger 🙂

… next we will explore the QT GUI Widgets.

Comments (3)

  1. Ludo says:

    Thanks for this info! What is the copyright or left on this? Because I'm compiling a small wiki of info to help my study for the exam and would like to include your summaries? I'm going to publish it to wikistudent when finished with it and I will but you down as a reference. is that ok?

    Ps. how much did you get for assignment 3?

  2. Feel free to share the information … the intention is to share 🙂

    Assignment 3 was a success … 100%.

  3. Ludo says:

    Thanks 🙂 and good luck with the exam next week!

Skip to main content