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.