Wk3

209 flashcardsby Sam
Study these flashcardsFree · spaced repetition · iPhone, Android, Mac & web

All cards

1
What is software architecture (SEI definition)?
The set of structures (elements, relationships, properties) needed to judge whether a system can meet key requirements
2
Does all software have an architecture?
Yes, whether designed or "just grown"
3
Why does architecture matter if the software works functionally?
Structure determines qualities beyond functionality, like ease of change and bug rate
4
What is one measure of overall software quality?
The effort required to meet the client's needs over the long term
5
What makes a software architecture "good"?
Its structures achieve the qualities considered important, possibly at the expense of less important ones
6
What is understandability as a quality attribute?
How easily developers can understand the software while working on it
7
What is modifiability as a quality attribute?
How easily the software can be added to or changed
8
Which two quality attributes are usually implicit goals of any software design?
Understandability and modifiability
9
Which quality often conflicts with understandability and modifiability?
Performance
10
What is testability?
Ease of applying test inputs and observing outputs to verify the software
11
What is portability?
Ease of transferring software to a different hardware or software platform
12
What is maintainability?
Ease of understanding, modifying and testing code
13
What three properties does software security preserve?
Confidentiality, integrity and availability
14
What is availability?
The software being usable when needed
15
What is scalability?
Ease of extending the software to handle larger loads
16
What is robustness?
Ability to respond well to abnormal conditions or edge cases
17
What is safety as a quality attribute?
Ability to avoid incorrect outputs or actions
18
What is the "conceptual model" architecture decision?
Which abstractions or data structures the system uses
19
What is the "allocation of responsibilities" architecture decision?
How functionality is split into subsystems and modules
20
What is the "allocation of behaviour" architecture decision?
How activities map to tasks or threads, and how those map to modules
21
What is the "coordination" architecture decision?
Whether and how parts of the system communicate
22
What is the "resource management" architecture decision?
How memory, peripherals and computing time are managed
23
What is the "binding time" architecture decision?
When in the lifecycle (build, run time, later) other decisions take effect
24
What three questions guide architecture design?
Which qualities matter, what structures achieve them, and how to communicate the decisions
25
How do you identify important qualities for an architecture?
From the requirements
26
What quality do requirements to do many things at once or respond quickly suggest?
Timing performance
27
What quality do memory or power constraints suggest?
Resource performance
28
What qualities do requirements to handle errors suggest?
Safety, robustness, testability or availability
29
Why must you identify likely modifications, not just "modifiability"?
No design can support every possible change equally
30
What is the Information Hiding principle?
Components share as little information as possible; changeable decisions are hidden behind stable interfaces
31
What is the Minimal Communications principle?
Components communicate with as few others as possible through the smallest interfaces
32
What is the Direct Mapping principle?
Components map clearly to problem-domain concepts
33
What is the Single Responsibility principle (architecture level)?
Each component is responsible to one stakeholder, so has one source of reasons to change
34
What is the Open-Closed principle?
Components are open for extension but closed for modification
35
What is the Dependency Inversion principle?
Components should depend on stable abstractions rather than concrete details
36
Which two principles together increase "orthogonality"?
Information Hiding and Minimal Communications
37
What are the SOLID principles mentioned in architecture?
Single Responsibility, Open-Closed and Dependency Inversion (among others)
38
What is an architectural pattern?
A recurring structural template that is a good starting point for a design
39
Can multiple architectural patterns be combined?
Yes, they can be used together or nested
40
What is the Layered architecture pattern?
Software split into layers, each serving the layer above through a defined interface and only talking to adjacent layers
41
What is a common embedded example of a layered architecture?
A Hardware Abstraction Layer (HAL)
42
Which qualities does a layered architecture support?
Portability and modifiability
43
Is "software architecture" the same as "creating some layers"?
No, layering is just one pattern
44
What is the Ports and Adapters (Hexagonal) pattern?
Core logic talks to the outside only through abstract ports; adapters convert each external device to a port interface
45
What is the main emphasis of Ports and Adapters?
Separating external interactions from internal logic
46
Which qualities does Ports and Adapters support?
Portability, testability and modifiability
47
What is the Microkernel pattern?
A core of common services with problem-specific components plugged in
48
What is a common embedded example of a microkernel architecture?
An RTOS with tasks running on it
49
Which principle does the Microkernel pattern commonly implement?
Open-Closed
50
What is the Pipes and Filters pattern?
Data-transforming components (filters) connected by possibly buffered pipes
51
Where is Pipes and Filters common?
Signal processing systems
52
Which qualities does Pipes and Filters support?
Modifiability (loose coupling) and performance (parallelism)
53
What is an Architecture Haiku?
A terse one-page document of purpose, key structure, driving requirements, trade-offs and rationale
54
What is an Architecture Decision Record (ADR)?
An incremental record of a decision: the concern, options considered and reasons
55
What are the sections of an ADR?
Context, Decision, Consequences
56
What statuses can an ADR have?
Proposed, Accepted, Rejected, Superseded
57
What is the C4 model?
A lightweight approach to diagramming software architecture
58
What is a limitation of C4 diagrams?
They show structure but need extra documentation to explain why
59
How can you evaluate whether an architecture achieves its goals?
By assessing it against scenarios that capture quality requirements
60
What is a very lightweight scenario evaluation?
Check whether the architecture handles the scenario without changes
61
What is a lightweight scenario evaluation?
Assess the number and scope of changes needed
62
What is a more involved scenario evaluation?
Quantitative estimates of magnitude, complexity or cost of the changes
63
What good source of scenarios does agile offer?
User stories
64
What are architectural tactics?
Individual design decisions that influence quality attributes; patterns combine them
65
What is coupling?
Strength of relationships between elements in different modules
66
What is cohesion?
Strength of relationships between elements within the same module
67
To improve modifiability, what should happen to cohesion and coupling?
Increase cohesion, decrease coupling
68
Which of these are tactics to increase cohesion?
  • Split large modules
  • Group elements affected by the same change
  • Factor out common responsibilities
  • Add intermediaries
69
Which of these are tactics to decrease coupling?
  • Encapsulate behind stable interfaces
  • Use an intermediary like an adapter
  • Parameterise behaviour
  • Merge modules
70
What modifiability tactic involves timing?
Defer binding or configuration until later in the lifecycle
71
What are the two groups of timing performance tactics?
Control demand and manage resources
72
Which of these are tactics to control timing demand?
  • Reduce sampling rate
  • Limit event arrival rates
  • Prioritise events
  • Add more indirection
73
What timing tactic trades accuracy for speed?
Bounding execution time
74
What timing tactic conflicts with modifiability?
Eliminating intermediaries to reduce overhead
75
Which of these are tactics to manage resources for timing?
  • Increase resources
  • Introduce concurrency
  • Cache or precompute
  • Schedule limited resources
76
Which of these are testability tactics?
  • Executable assertions
  • Abstract data sources
  • Specialised test interfaces
  • Remove indirection
77
What other testability tactics exist besides assertions and test interfaces?
Keep state in one place, sandbox the system, replay recorded interactions
78
Why does modifiability often trade off with time performance?
It needs indirection, which adds overhead
79
Why does testability often trade off with time performance?
It needs indirection, which adds overhead
80
What is the classic trade-off between execution speed and resources?
Speed versus memory
81
Why can responsiveness trade off against power?
Responding fast may mean avoiding sleep wake-up latency
82
Why can determinism trade off against responsiveness?
Deterministic timing may require polling instead of reacting immediately to events
83
What is an example of abstraction costing performance?
Arduino digitalWrite() is about 20× slower than direct port writes
84
What are the steps of re-architecting?
Assess existing structures, list quality requirements, evaluate existing architecture, apply patterns/tactics and re-evaluate
85
What is a software "structure"?
A collection of elements and relationships between them
86
What are the three categories of software structure?
Static, dynamic and allocation
87
What are static structures?
Conceptual abstractions a developer works with (decomposition, dependency, class)
88
What are dynamic structures?
Relationships in executing software (collaboration, data-flow, task)
89
What are allocation structures?
Mapping of software to external things (memory map, implementation, deployment)
90
In a decomposition structure, what is the relationship?
"Submodule of"
91
In a dependency structure, what is the relationship?
"Depends on"
92
In a class structure, what are the relationships?
Inheritance and association
93
In a data-flow structure, what are the elements?
Processes and stores, connected by flows of data
94
In a task structure, what are the elements?
Tasks and objects, connected by interactions
95
In a memory map structure, what are the elements?
Data and addresses
96
In a deployment structure, what are the elements?
Software and hardware
97
Which views help reason about modifiability and testability?
Decomposition or class views
98
Which views help reason about portability?
Dependency/layer and memory map views
99
Which views help reason about security and safety?
Data-flow and collaboration views
100
Which view helps reason about task performance and availability?
Task view
101
Which view is often used for security threat modelling?
Data-flow diagrams
102
What three properties should a concurrent program maintain?
Safety, liveness and responsiveness
103
What is safety in concurrency?
Nothing bad ever happens; no incorrect state is reached
104
What is liveness?
Something useful eventually happens; the program makes progress
105
What is responsiveness (bounded liveness)?
The program makes progress within a deadline
106
Why is concurrency introduced into embedded systems?
To improve maintainability and responsiveness of independent activities
107
What property does concurrency typically compromise?
Safety
108
When do safety failures from concurrency occur?
When tasks make uncoordinated changes to a shared resource
109
What is an interleaving?
A possible mixed sequence of actions from concurrent tasks, each keeping its own order
110
What is a race condition?
An unpredictable outcome that depends on the interleaving of actions
111
What is a critical section?
Code sensitive to race conditions that must execute atomically
112
What is an atomic action?
An action that executes as one uninterruptible unit
113
In preemptive execution, what is usually the atomic unit without concurrency control?
A single machine instruction
114
Is a single C statement like counter = counter + 1 atomic?
No, it compiles to several load/add/store instructions
115
Why is counter = counter + 1 unsafe across tasks?
A context switch mid-update can overwrite another task's change
116
What should you assume about interleavings when analysing concurrent code?
Any interleaving could happen
117
What advantage does cooperative scheduling have for concurrency?
Each task controls when others run, so it defines its own atomic sections
118
What are the four strategies to prevent race conditions?
Immutability, atomic data, synchronization, containment
119
What is the immutability strategy?
Never change shared values once created
120
What is a memory-friendly alternative to immutability?
Allow only one owner of a memory chunk at a time
121
What is the atomic data strategy?
Share only data that can be updated atomically
122
What is the synchronization strategy?
Force tasks to align at points so changes appear atomic
123
What is the containment strategy?
One task owns the resource; others interact only via messages
124
Which two race-prevention strategies are the most flexible?
Synchronization and containment
125
Which strategy does disabling interrupts around a critical section use?
Synchronization
126
Which strategy does a FreeRTOS message queue implement?
Containment (plus immutability, atomic data and internal synchronization)
127
What is a mutex?
A lock that only one task can hold at a time; others block until it is released
128
What does "mutex" stand for?
Mutual exclusion
129
Which FreeRTOS function creates a mutex?
xSemaphoreCreateMutex
130
Which FreeRTOS function locks a mutex?
xSemaphoreTake
131
Which FreeRTOS function unlocks a mutex?
xSemaphoreGive
132
What type is a FreeRTOS mutex handle?
SemaphoreHandle_t
133
Which header is needed for FreeRTOS mutexes and semaphores?
semphr.h
134
What concurrency property can blocking compromise?
Liveness
135
What is deadlock?
Tasks waiting on each other so none make progress
136
What condition causes deadlock?
A circular wait (cycle of ungranted requests)
137
Can a single task deadlock itself?
Yes, e.g. by taking a mutex it already holds
138
What kind of mutex avoids a task deadlocking on its own lock?
A recursive mutex
139
What is livelock?
Tasks aren't blocked but keep cycling without progress
140
What can cause livelock?
Using timeouts to escape deadlock
141
Two tasks each take one of two mutexes then try for the other. What happens?
Deadlock
142
What is the basic rule to avoid mutex deadlock?
Always acquire mutexes in the same order
143
Can deadlock occur in purely message-based systems?
Yes, if tasks block waiting for responses in a cycle
144
What is the bug in a task that takes a mutex in one branch but always gives it at the end?
Mutex takeive are unbalanced, and the mutex is held during the delay
145
What are two tactics to avoid circular waits?
Restrict connection directionality and minimise circular dependencies
146
What is a pipeline task structure?
Data flows one way through a chain of tasks, each transforming it
147
Why can't a pipeline deadlock?
It contains no cycle of tasks
148
Can a pipeline branch?
Yes
149
What is a client-server task structure?
A client initiates requests; a server passively waits and responds
150
Why can't client-server deadlock?
The server only waits for requests and the client only waits for responses
151
How many servers can a client interact with at once?
Only one at a time
152
Can a server act as a client to other servers?
Yes, forming a tree with no cycles
153
Should a server task initiate interactions with its clients?
No
154
What is a Synchronized ADT?
A passive module that encapsulates a resource behind functions with internal synchronization
155
What is another name for a Synchronized ADT variant?
Monitor object
156
When is a Synchronized ADT a good choice?
When a synchronous response is needed and blocking won't delay other tasks
157
What are the benefits of a Synchronized ADT?
Mutexes aren't scattered, clients can't touch them, and lock order is enforced in one module
158
Should Synchronized ADTs call other Synchronized ADTs?
No, it risks deadlock
159
What is a server task in concurrency design?
A task that contains a resource and serves requests through a message interface
160
What is another name for the server task pattern?
Active object
161
When is a server task a good choice?
When background work is needed, or long critical sections shouldn't block callers, and async responses are acceptable
162
What task pattern should a server task use?
Event-driven
163
What is priority inversion?
A high-priority task is blocked by a low-priority task holding a mutex, which is itself preempted by a medium task
164
What is the consequence of priority inversion?
The high-priority task may miss its deadline
165
What is priority inheritance?
A low-priority task blocking a higher one temporarily inherits the higher priority
166
Does FreeRTOS support priority inheritance?
Yes, for mutexes
167
What is better than priority inheritance?
Avoiding priority inversion altogether
168
What is starvation?
Some tasks can't progress because they can't get resources or CPU time
169
When is starvation most likely among non-critical tasks?
When several share the same priority
170
How does time slicing help prevent starvation?
Equal-priority tasks share CPU time round-robin
171
What is a fair mutex?
One that ensures every waiting task eventually acquires it, e.g. by queuing
172
Are FreeRTOS mutexes known to be fair?
No
173
What is a semaphore?
A synchronization tool with an atomic count; decrementing below zero blocks the task
174
What is a binary semaphore?
A semaphore whose count is only 0 or 1
175
How does a mutex differ from a binary semaphore?
A mutex starts released and should only be released by its holder; a semaphore can be given by any task
176
When should you use a mutex vs a semaphore?
Mutex to protect shared resources; semaphore to signal between tasks
177
Which FreeRTOS function creates a binary semaphore?
xSemaphoreCreateBinary
178
How does a task wait for a semaphore signal?
xSemaphoreTake
179
How does a task send a semaphore signal?
xSemaphoreGive
180
Besides mutexes and semaphores, what other FreeRTOS signalling tool exists?
Task notifications
181
What is legacy code (Michael Feathers)?
Code without tests
182
Why is hacking new features into messy code a bad option?
It adds to the mess and easily introduces bugs
183
Why is rewriting from scratch often a bad option?
It's time-consuming, means maintaining two versions, and brings new bugs
184
Why is refactoring without tests risky?
There's no guarantee functionality is preserved
185
What is the entry point to making legacy code changeable?
Adding tests
186
What are the three ways to prioritise tests for legacy code?
Targeted, characterisation and strategic tests
187
What are targeted tests?
Tests added where code needs to change
188
What is the targeted test policy?
Test where change is needed, test-drive changes and new code, then refactor
189
What is the Boy Scout rule?
Leave the code cleaner than you found it
190
What are the benefits of targeted tests?
Iterative, as-needed, and still allows feature delivery
191
What are characterisation tests?
Tests written to capture and verify understanding of existing behaviour
192
Do characterisation tests aim to fix bugs?
No, only to document actual behaviour
193
When does actual behaviour become the specification?
When the documentation is outdated
194
What are strategic tests?
Tests added proactively to protect key functionality
195
Give an example of where strategic tests are valuable
A flight controller's control algorithm or a medical device's safety checks
196
What are the four steps to put legacy code under test?
Identify the area, find test points, break dependencies, write tests
197
What is a test point?
A place in code where you can control the code under test and observe its effects
198
Which test point is most effective?
Function calls
199
What should be done with existing global variables used as test points?
Encapsulate them as soon as possible
200
Why do stable interfaces make the best test points?
They don't change during refactoring, so tests aren't fragile
201
What is a fragile test?
One that must change whenever the code is refactored
202
What does "breaking dependencies" mean?
Isolating the code under test from the rest of the application
203
What can you do when dependencies seem unbreakable?
Make the smallest refactoring to create test points, possibly a temporary global
204
How should risky pre-test changes be made safer?
Rigorous manual testing and a colleague's review
205
How can main() be excluded from unit tests via the preprocessor?
Rename it with a macro under a UNIT_TEST define
206
What is the cost of preprocessor "hacks" for testing?
They introduce technical debt
207
How can an infinite task loop be tested?
Use a macro so the loop runs once under UNIT_TEST
208
What is the alternative to preprocessor hacks for testability?
Extract code into a separate module or function and cover the change with manual tests
209
How do testing and clean code relate?
Testability and clean design reinforce each other, together making code changeable
Study all 209 cards for free