Courses / Machine Coding and Low-Level Design in TypeScript / Chapter 3
Module 2 · Objects and object-oriented design · Chapter 3 of 28
Object-Oriented Design and UML: Use Case, Class, Sequence, Activity and State Diagrams
Builds on The Machine Coding and LLD Round: Format, Scoring and a Method and Cornerstones of OOP in TypeScript: Encapsulation, Abstraction, Inheritance, Polymorphism. Next up: Design Principles: SOLID, DRY, KISS, YAGNI and the Law of Demeter.
Part 1 · From requirements to objects
Reading a requirement for nouns and verbs
A design starts as a paragraph of requirements and ends as boxes and arrows a programmer can implement. This chapter shows how to find the objects, and how to draw the five kinds of UML diagram that describe them.
Take a short requirement for a clinic app. "A clinic has doctors. A patient books an appointment with a doctor for a time slot. A receptionist can cancel an appointment. A reminder message goes out the day before." The first pass is mechanical. Underline the nouns, they are candidates for classes. Underline the verbs, they are candidates for methods.
| Noun or verb | Becomes | Why |
|---|---|---|
| Doctor, patient, appointment | Entities | Each one has an identity that persists as its details change |
| Time slot, fee | Value objects |