COS3711 EXAM
PACK 2024
QUESTIONS AND
ANSWERS
FOR ASSISTANCE CONTACT
EMAIL:
, lOMoARcPSD|31863004
COS3711 Summary
For: An Introduction to Design Patterns in C++ with Q
By: Wilco Breedt
, lOMoARcPSD|44660598
1. UML Class Diagrams
A UML class diagram represents the static structure of a system, showing how classes are
related. Here’s what you should focus on:
• Classes: Represent entities with attributes and methods.
• Relationships: Use arrows to show inheritance, aggregation, composition,
and associations.
• Attributes and Methods: Represent key data and operations in the classes.
Example: Book and Magazine Tracking System (From 2023 Paper )
Let’s assume we are tasked with creating a system to track books and magazines. Both
have names, and books have publishers, while magazines have frequencies.
Class Diagram Requirements:
• An Item class with basic attributes (name).
• Two subclasses Book and Magazine, inheriting from Item.
• The Client class, which holds a list of items (QList<Item*>).
Here’s a basic UML class diagram:
• Item: +name: QString (parent class)
• Book: +publisher: QString (inherits from Item)
• Magazine: +frequency: QString (inherits from Item)
• Client: -items: QList<Item*>
, lOMoARcPSD|44660598
This diagram shows:
• Inheritance: Books and magazines inherit from Item.
• Aggregation: The Client class contains a list of Item.
Key Tips for UML Diagrams:
• Use arrows for inheritance (open arrowheads).
• Use diamonds for aggregation (white) or composition (black).
• Don’t clutter diagrams with too many details; focus on key classes,
attributes, and relationships.
2. Design Patterns
Design patterns are recurring solutions to common software design problems. In
COS3711, you focus on Strategy, Singleton, and Factory Method patterns.
a. Strategy Pattern
This pattern is used to define a family of algorithms, encapsulate each one, and make them
interchangeable.
Example: Communication System (From 2021 Paper )
In the communication system, users can send messages via Signal, SMS, or WhatsApp.
Steps to Implement:
PACK 2024
QUESTIONS AND
ANSWERS
FOR ASSISTANCE CONTACT
EMAIL:
, lOMoARcPSD|31863004
COS3711 Summary
For: An Introduction to Design Patterns in C++ with Q
By: Wilco Breedt
, lOMoARcPSD|44660598
1. UML Class Diagrams
A UML class diagram represents the static structure of a system, showing how classes are
related. Here’s what you should focus on:
• Classes: Represent entities with attributes and methods.
• Relationships: Use arrows to show inheritance, aggregation, composition,
and associations.
• Attributes and Methods: Represent key data and operations in the classes.
Example: Book and Magazine Tracking System (From 2023 Paper )
Let’s assume we are tasked with creating a system to track books and magazines. Both
have names, and books have publishers, while magazines have frequencies.
Class Diagram Requirements:
• An Item class with basic attributes (name).
• Two subclasses Book and Magazine, inheriting from Item.
• The Client class, which holds a list of items (QList<Item*>).
Here’s a basic UML class diagram:
• Item: +name: QString (parent class)
• Book: +publisher: QString (inherits from Item)
• Magazine: +frequency: QString (inherits from Item)
• Client: -items: QList<Item*>
, lOMoARcPSD|44660598
This diagram shows:
• Inheritance: Books and magazines inherit from Item.
• Aggregation: The Client class contains a list of Item.
Key Tips for UML Diagrams:
• Use arrows for inheritance (open arrowheads).
• Use diamonds for aggregation (white) or composition (black).
• Don’t clutter diagrams with too many details; focus on key classes,
attributes, and relationships.
2. Design Patterns
Design patterns are recurring solutions to common software design problems. In
COS3711, you focus on Strategy, Singleton, and Factory Method patterns.
a. Strategy Pattern
This pattern is used to define a family of algorithms, encapsulate each one, and make them
interchangeable.
Example: Communication System (From 2021 Paper )
In the communication system, users can send messages via Signal, SMS, or WhatsApp.
Steps to Implement: