Wk4

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

All cards

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