CS2002 - Week 8 - Software Architecture & Design Patterns

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/16

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

17 Terms

1
New cards

Why use design patterns?

  • Reusability: Pre-tested solutions

  • Communication: Shared vocabulary

  • Maintainability: Organised code

  • Scalability: Adaptable structure

2
New cards

How does the Singleton pattern ensure a single instance?

Using a private constructor, static instance variable, and public getInstance() method

3
New cards

Name two creational patterns and their purposes

  • Factory: Creates objects without specifying classes

  • Builder: Constructs complex objects step-by-step

4
New cards

What are the 3 MVC components?

  1. Model: Manages data

  2. View: Displays data

  3. Controller: Handles input

5
New cards

MVC flow for a bank transfer

User -> Controller (initiateTransfer)

Controller -> Model (validateTransfer, updateBalance)

Controller -> View (displayUpdateBalance)

6
New cards

MVC maintainability

Changes to one component (e.g View) don't affect others (Model/Controller)

7
New cards

Adapter pattern

Incompatible interfaces -> compatible

8
New cards

Decorator pattern

Adds responsibilities dynamically

9
New cards

Observer pattern

Objects (observers) get notified of change

10
New cards

Why is MVC easier to test?

Components are isolated

11
New cards

How to make Singleton thread-safe?

Use synchronised in getInstance() or static initialisation

12
New cards


Name an MVC variant

MVVM (Model-View-View-Model) for data-binding (e.g. Angular)

13
New cards

When should you use design patterns?

When they solve a specific problem - not as a default. Overuse adds complexity

14
New cards


Name two structural patterns

  • Adapter: Incompatible interfaces -> compatible

  • Decorator: Adds responsibilities dynamically

15
New cards

What does the Model do in MVC?

Stores data, Enforces business rules, Notifies View of updates

16
New cards

What is the View’s role in MVC?

Displays data from Model, No business logic, Updates when Model changes

17
New cards

What does the Controller handle?

Processes user input, Updates Model, Refreshes View