2IRR00 · resource
Revision summaries
Foundations
- Design = abstractions of data+computation organised into a working app (Robillard); process + outcome.
- No single right design — trade off maintainability, reusability, security, performance.
- Design exists to prevent bugs & aid humans; failures: bad requirements, missing checks, poor communication.
Processes & Requirements
- Waterfall (linear, frozen specs); V-Model (Waterfall + testing, safety-critical); Spiral (risk/cost loops); Prototyping (feedback).
- Agile manifesto = 4 'X over Y' values (Y not ignored). Scrum: 3 roles, 5 events, artifacts; DoR vs DoD.
- Requirements: Functional / Quality / Constraint. SMART. MoSCoW (Must/Should/Could/Won't).
UML
- Use case: include = always; extend = optional. Don't model processes here.
- Class: abstract = no instance; composition (◆ deleted together) vs aggregation (◇ independent); 'has' vs 'can see'.
- Activity: each decision→merge, each fork→sync; don't mix them.
Quality & Testing
- Verification (right-built) vs validation (right product). Robust = always throws on precondition violation.
- @pre = client's fault; @post = bug. Avoid catch(Exception e): not contract-aligned + unclear.
- Equivalence classes/boundaries; each test = purpose+input+output+pass/fail. TDD: red-green-refactor.
Version Control
- Centralized = one server, only current version (no history). Distributed = full local copy + history.
- add (stage) → commit (LOCAL) → push (remote). HEAD = latest commit.
- Branch lives in repo; fork is independent (PR to merge). Don't commit .class/executables.
Manageable Code
- Separation of concerns / divide & conquer. Encapsulation = data+ops in a unit, controlled interface.
- Coupling = between units (minimise); cohesion = single purpose (maximise). DRY.
- Encapsulation MCQ: relevant data in one unit + access via interface (not DRY, not god class).
Reusable Code
- Abstract class (single inheritance, mixed methods) vs interface (multiple, all abstract).
- Enum: fixed named constants, type safety, optional ctor, NOT runtime-created. Record: data carrier.
- SOLID (S,O,L,I,D). 'Separation of concerns' is NOT SOLID. KISS.
Creational Patterns
- Polymorphism: ad-hoc/overload, subtyping/override, parametric/generics. Generics = compile-time type safety.
- Singleton: private static instance + private ctor + getInstance; lazy not thread-safe; downsides = global access, SRP, coupling.
- Factory decouples creation from concrete classes (avoids 'new' dependency-inversion violation).
Concurrency, GUI & Command
- Race condition = interleaving on shared memory; start() (thread) vs run() (inline).
- SwingWorker<T,V>: T=result, V=intermediate; doInBackground/process/done; execute() to start; keeps GUI responsive.
- Command = request-as-object, decouple data from call moment; undo/redo with stacks (+ revert()).
Structural Patterns
- Decorator: add behaviour to an OBJECT at runtime via wrapping (composition); alt to inheritance.
- Facade: one unified interface hiding a subsystem (≠ blob). SwingWorker is a facade.
- == reference vs equals() content; override equals + hashCode together; instanceof before casting.
MVC & Observer
- MVC: Model/View/Controller; defines WHAT to separate not HOW; can use decorator for views (not 'must use factory').
- Observer = one-to-many auto-update. Push: subject sends data (more coupling).
- Pull: subject notifies only, observer pulls via getters (less coupling, maybe less efficient).
Behavioral Patterns
- Strategy: interchangeable algorithms, composition, runtime swap. Iterator: traverse without exposing structure.
- Template Method: fixed skeleton + overridable steps (inheritance, class-level).
- State ≡ Strategy structurally; State = complete behaviour change + linked states. Template vs Strategy: inherit/compose, parts/whole, static/dynamic.
Smells & Refactoring
- Smell = subjective symptom; defect = actual misbehaviour. Name ≥4: blob, duplicate code, dead code, long parameter list…
- Refactoring = change structure, NOT behaviour (so a bug fix isn't refactoring).
- Technical debt = short-term gain, long-term compounding cost.