Skip to main content

Cohesion, Coupling, and SOLID Lab

Attempt these five tasks before opening feedback. Keep a contract, observation, candidate change, alternative and verification limit. These P tasks are required; extra lesson drills are targeted repair or optional depth.

P01: Separate evidence from taste​

Order exposes total, save and render. Name two independently changing policies, a plausible separation and one context where keeping the small module intact is reasonable.

P02: Track the alias​

A history getter returns tuple([mutable_transaction]). Show a sequence that changes a retained observation without adding/removing an outer element. State a repair and its cost.

P03: Write a transition contract​

For opening balance 10, specify deposit, withdraw, zero, insufficient funds, negative input and currency mismatch. Give the expected public trace for withdraw 12, deposit 5, withdraw 3.

P04: Substitution under a real contract​

A mutable rectangle promises independent width/height setters. Give a valid client that a square subtype breaks. Then define a read-only shape contract both can satisfy.

P05: Test a client role​

Implement a fake exposing only balance() and use it with statement. Explain what this demonstrates about the consumer and what it cannot establish about all account implementations.

Reuse lab evidence and record assistance. If a book gap remains, locate the topic through the Refactoring book index and the selective reading guide.