Design Principles Flashcards
bad software design exhibits at least one of which 3 traits?
Rigidity, Fragility or Immobility (While still satisfying main requirements)
Define: Rigidity
Rigid if software is hard to change, because every change effects many other parts of the system
Define: fragility
System is fragile if, when changes are made, unexpected parts of the system break
Define: Immobility
Immobile if system is hard to use in another app, because it is difficult to disentangle from current app
Define: System
A set of cohesive modules working together to satisfy a set of requirements
Define: Pre-Condition
Checking the validity of an input before it is used
Define: Post-Condition
Condition that must evaluate to true after the execution of some code
Define: Coupling
How reliant a module is on its neighbors
Define: Cohesion
The strength of a relationship between a module and its neighbors
Define: System Boundary
The definition of what aspects are part of the system, and which aspects are not.
Define: Single Responsibility Principle
every module or class should have responsibility over a single part of the functionality provided by the software, and that responsibility should be entirely encapsulated by the class
Rule for connections between modules
If a system has n modules, the # of connections should be closer to (n-1) than to (n(n-1)/2)
Layers vs. Partitions
Layers: Reliant on other layers to function Increases coupling
Partitions: Not reliant on other partitions to function. Decreases coupling
Perks of high cohesion?
Complexity is manageable
Good code readability and reusability
Features of Modularity
De/Recomposability
Understandability
Continuity
Protection
Define: Modular Continuity
System satisfies continuity if a small change to the specification triggers a change in only one/few modules
Define: Modular Protection
System satisfies protection if, when an abnormal condition occurs at runtime, the effect of such will either stay confined to that module or to few neighboring modules
Define: Modular Understandability
System satisfies modular understandability if its modules can be understood independently/mostly independently
Define: Modular Reusability
Components should be sufficiently independent from their source of existence
Why are modules w/ high coupling undesirable?
A change in one module usually forces a ripple effect of changes in other modules. Assembly of modules might require more effort and/or time due to the increased inter-module dependency. A particular module might be harder to reuse and/or test because dependent modules must be included.
Countermeasures in a class with low cohesion?
Try to group like functionalities into another class
Pro/Cons of Manager Objects?
Pros:
Related functionalities are grouped.
Easier to manage components from single location.
Cons:
Violates the ‘single responsibility principle’, class is less robust as a result
Define: Modular Decomposability
If construction method helps to break up a large software problem into smaller less complex sub-problems, we consider it to be modularly decomposable