Assignment 2
Advanced Programming
Due 18 JULY 2025
,COS3711 Assignment 2: Advanced Programming
Due 18 JULY 2025
The code executes flawlessly, delivering reliable and efficient performance
without any errors.
This response addresses Question 1 of the COS3711 Assignment 2 (2025) from the
University of South Africa, as outlined in the provided assignment tutorial letter. The
task requires implementing a Qt-based Store Application to track customer purchases
and a UDP Receiver Application to display broadcasted transaction data in XML format.
The response is structured to meet postgraduate-level academic rigor, providing a
comprehensive analysis followed by complete source code for both applications. It
adheres to the assignment’s requirements, including the use of CMake, QMainWindow,
manual GUI construction, object-oriented programming (OOP) principles, design
patterns (Singleton, Memento, MVC), and proper memory management using Qt’s
parent-child mechanism. Bonus features (splash screen, application icon, toolbar,
extended data members) are included, and good programming practices (naming
conventions, initializer lists, clean code layout) are followed.
1. Content: Analysis and Design
1.1 Overview of Requirements
The assignment specifies the development of two distinct applications:
• Store Application: Tracks customer purchases and manages items (books and
magazines). It records transactions, displays them in a tree model, and
broadcasts transaction data in XML format via UDP. Key implementation
requirements include the use of QMainWindow, CMake, and manual GUI setup
(without Qt Designer).
, • UDP Receiver Application: Listens for UDP broadcasts from the store
application and displays the received XML data on a GUI.
General Requirements:
• Strict adherence to object-oriented programming (OOP) principles.
• Use of pointers with Qt’s parent-child memory management model.
• Application of design patterns to ensure scalable, maintainable architecture.
• Good programming practices such as meaningful naming conventions, initializer
lists, and clean code layouts.
Bonus Features:
• Splash screen, application icon, toolbar, About/Help dialogs.
• Extended item data members (e.g., price and stock).
1.2 Critical Analysis of Requirements
1.2.1 Store Application
The store application necessitates a robust data management system to handle
customers, items, and transactions efficiently. The requirement for a tree model
suggests a hierarchical data structure, suitable for grouping transactions by customer.
This aligns with the Model-View-Controller (MVC) design pattern (Gamma et al.,
1994), ensuring separation of concerns between data handling, user interface, and
control logic.
To prevent multiple copies of customer and item lists, implementing the Singleton
pattern is appropriate, ensuring a single instance of these lists throughout the
application (Gamma et al., 1994). The Memento pattern is also relevant for enabling
item list backups and restoration without compromising data integrity (Gamma et al.,
1994).
Additionally, UDP broadcasting in a separate thread introduces concurrency
challenges, necessitating thread-safe data access mechanisms such as QMutex. The