1What do software engineers produce as their "design document"?
Source code
2How does the cost of build compare to the cost of design in software engineering?
Build cost is negligible compared to design cost
3How does software build cost compare to structural engineering?
Structural build cost is far greater than design cost; software build cost is negligible
4Why should software design strategy differ from other engineering disciplines?
Because builds are nearly free, allowing frequent iterative changes
5What development approach is based on the low cost of software builds?
Agile, an iterative approach to design
6What does the Agile Manifesto value over processes and tools?
Individuals and interactions
7What does the Agile Manifesto value over comprehensive documentation?
Working software
8What does the Agile Manifesto value over contract negotiation?
Customer collaboration
9What does the Agile Manifesto value over following a plan?
Responding to change
10Does the Agile Manifesto say the right-hand items have no value?
No, they have value but the left-hand items are valued more
11Name signatories of the Agile Manifesto
- Kent Beck
- Robert Martin
- James Grenning
- Erich Gamma
12What is the waterfall model?
A sequential process: requirements, design, develop, test, deploy, maintenance
13What is the main problem with waterfall for embedded software?
It repeatedly gives inadequate results because it handles change poorly
14What triggers the vicious cycle of an inflexible development process?
Vague or changing requirements leading to unrealistic plans
15What follows unrealistic plans in the vicious cycle?
Late projects, schedule pressure, long hours, mistakes, poor quality, missed expectations
16What is the ultimate outcome of the inflexible development cycle?
Lost business
17What is issue tracking good for?
Tracking ever-changing requirements
18What must be done with an issue backlog?
Size and prioritise issues to plan each iteration
19What are the three sources (axes) of change in embedded software?
Functional requirements, hardware, third-party libraries
20Why do functional requirements change?
Customers don't know what they want until they see it; engineers don't know the best solution until they try
21Why does hardware change in embedded projects?
Software developed in parallel with hardware, market shortages and obsolescence
22Why do third-party libraries change?
Feature updates, bug fixes, licensing issues, better alternatives
23What does SOLID stand for?
Single Responsibility, Open-Closed, Liskov Substitution, Interface Segregation, Dependency Inversion
24Who first formally put together the SOLID principles?
Robert C. Martin
25What do the SOLID principles help manage?
Code dependencies, so the system responds well to change
26What is the problem with a module that both handles hardware and processes application data?
Two sources of change are coupled in one module
27What is a Hardware Abstraction Layer (HAL)?
A module that abstracts away hardware details behind a set of functions
28How can a C header file act as an abstract interface?
Keep it generic, with the .c file implementing the platform-specific details
29Can a C header and its implementing .c file have different names?
Yes
30What is polymorphism?
Using a single symbol to represent multiple different types
31How is polymorphism achieved with a HAL interface?
Different implementations (e.g. different MCUs or a mock) satisfy the same interface
32What two concepts are key to implementing SOLID between modules?
Abstraction and polymorphism
33What is the Single Responsibility Principle (SRP)?
A module should have one responsibility and only one reason to change
34How can you identify "one reason to change"?
Think about the sources of change the module is responsible for
35What is a sign a module violates SRP?
It accesses numerous data structures and globals
36What is the Open-Closed Principle (OCP)?
Software entities should be open for extension but closed for modification
37How is OCP achieved?
Through abstraction, so changes are made by adding new code
38What is an analogy for OCP?
A computer's USB port — the USB standard is the abstraction
39In C, what can be used as abstractions for OCP?
Header files or function pointers
40In OO languages, what is the abstraction for OCP?
An interface or abstract class
41What is the Liskov Substitution Principle (LSP)?
Subtypes should be substitutable for their base types
42What does LSP emphasise beyond syntax?
Semantics — implementations must behave as the interface expects
43What is an LSP violation example?
One light controller needing two "On" calls to stay on when others need one
44When does LSP become more of a problem?
When there are many subtypes
45What is the Interface Segregation Principle (ISP)?
Clients should not depend on functions they don't use
46How should interfaces be designed under ISP?
Small and tailored to the client's needs
47What does ISP improve?
Portability and testability, by limiting dependencies
48What is the Dependency Inversion Principle (DIP)?
High-level modules shouldn't depend on low-level modules; both should depend on abstractions
49Why does structural dependency normally follow flow of control?
High-level code naturally calls (and includes) low-level code
50How does DIP change dependency direction?
Structural dependency opposes the flow of control
51Why invert dependencies?
To protect important high-level policy from low-level details
52In UML class diagrams, what does a solid arrow mean?
Depends on
53In UML class diagrams, what does a dashed arrow with a hollow triangle mean?
Implements (realisation)
54In UML, what does + mean before a function?
Public
55In UML, what does - mean before a function?
Private
56What are the four models for applying SOLID in C?
Single instance module, multiple instance module, dynamic interface, per-type dynamic interface
57What is a single instance module?
One implementation whose functions match the interface names, bound by the linker
58How is the implementation chosen in a single instance module?
By including the chosen .c file in the build
59What binding and instancing does a single instance module have?
Single instance, static binding
60What is a multiple instance module?
An abstract data type with public functions operating on instances, f(O, x)
61What binding and instancing does a multiple instance module have?
Multiple instance, static binding
62What is an abstract data type (ADT) in C?
A type whose struct definition is hidden in the .c file, exposed only as a declared typedef
63What is a dynamic interface?
A public struct of function pointers populated at runtime with the chosen implementation
64What problem does a dynamic interface solve?
Switch-case "shotgun surgery" when choosing variants at runtime
65What binding and instancing does a dynamic interface have?
Single instance, dynamic binding
66What is a per-type dynamic interface?
Supports any number and mix of implementation instances at runtime
67What binding and instancing does a per-type dynamic interface have?
Multiple instance, dynamic binding
68What is the trade-off when choosing a SOLID model in C?
Flexibility versus added complexity
69How much design flexibility should you implement?
The simplest flexible design for today's requirements
70What should you do when requirements change?
Change the design with them
71What ensures functionality is retained when the design changes?
Tests
72Is needless complexity a design smell?
Yes
73Why might C++ be easier for SOLID than C?
Object-oriented features make abstraction and polymorphism simpler
74What is a design principle?
A general guideline for good software design
75What is a design pattern?
A typical solution to a commonly occurring software design problem
76What is an implementation, compared to a pattern?
A concrete solution customised for a specific problem
77In which engineering field were design patterns first used?
Civil engineering
78What is the "Gang of Four" (GoF)?
The four authors of the 1994 book Design Patterns
79Who are the Gang of Four?
Gamma, Helm, Johnson and Vlissides
80How many patterns are in the GoF book?
23
81What are the three types of GoF patterns?
Creational, structural, behavioural
82What do creational patterns do?
Help create instances of objects
83What do structural patterns do?
Set up communication pathways between modules
84What do behavioural patterns do?
Partition system behaviour by distributing responsibilities
85What common goal do all design patterns pursue?
Dependency management
86How do design patterns relate to SOLID?
They are a crystallisation of the SOLID principles
87Which category is the Adapter pattern?
- Structural
- Creational
- Behavioural
88Which category is the Observer pattern?
- Behavioural
- Creational
- Structural
89Which category is the State pattern?
- Behavioural
- Creational
- Structural
90Which of these are creational patterns?
- Singleton
- Factory Method
- Builder
- Observer
91Which of these are structural patterns?
- Adapter
- Facade
- Proxy
- Strategy
92What five aspects describe a pattern?
What, why, how, when, pros and cons
93What is the Adapter pattern?
An adapter wraps a module to give it a more desirable interface
94What is an analogy for the Adapter pattern?
A power adapter
95What problem does the Adapter pattern solve?
Lets modules with incompatible interfaces collaborate and hides conversion
96How does the Adapter pattern work?
The adapter implements the client's expected interface and calls the service on its behalf
97When should you use an Adapter?
To hide cumbersome interfaces, hide data conversions, or make incompatible modules compatible
98Give embedded examples of adapters
HALs, device drivers, wrappers around third-party libraries
99Which SOLID principles does Adapter support?
SRP, ISP and LSP
100How does Adapter support SRP?
Interface compatibility is delegated to the adapter
101How does Adapter support ISP?
The client doesn't depend on service functions it doesn't use
102How does Adapter support LSP?
It makes the service substitutable for the type the client requires
103What is the downside of Adapter?
Added complexity from more interfaces and modules
104What is the Observer pattern?
A component notifies registered components when specific events occur
105What is another name for the Observer pattern?
Publish/subscribe
106What is an analogy for the Observer pattern?
Subscribing to forum post notifications
107What problem does Observer solve?
Routes events to destinations without needless polling
108How does an observer subscribe in C?
It passes its event handler as a function pointer to the event issuer
109What does the event issuer keep in the Observer pattern?
A list of observer function pointers, all called when the event occurs
110When should you use Observer?
When the issuer shouldn't know its observers, or observers change dynamically
111Which SOLID principle does Observer support?
Open-Closed — observers can be added without modifying the issuer
112Can observers be changed at run time?
Yes
113What are the downsides of Observer?
Observers are notified in unknown order; dynamic subscription complicates modelling and debugging
114What is the State pattern?
A module behaves differently depending on its internal state
115What is an analogy for the State pattern?
A phone's lock button
116What problem does the State pattern solve?
Implements an FSM without lengthy switch/case conditionals
117How does the State pattern work?
A context holds a currentState; each concrete state implements a common State interface, and the context delegates calls to it
118Who initialises the context with a state?
The client
119When is the State pattern suitable?
FSMs with many states, many state-dependent functions, or frequent change
120Which SOLID principles does the State pattern support?
SRP and OCP
121How does the State pattern support SRP?
Each state's behaviour is in its own module, separate from the context
122How does the State pattern support OCP?
New states can be added to extend functionality
123What is the downside of the State pattern?
Overkill for few states where if/else suffices
124What is a key pitfall when using design patterns?
Needless complexity — design for today's requirements
125Must patterns be applied exactly as described?
No, customise them to suit the problem
126What is the "law of the instrument"?
If all you have is a hammer, everything looks like a nail