Advanced level · Module 1: Object-Oriented Programming in Python · Lesson 4 of 4
Designing Classes from Real Requirements
Turn a real-world process into a small set of well-designed classes before writing code.
In this lesson you will
- Identify classes, attributes and methods from a description of a process
- Sketch relationships between classes and check them against requirements
Key concepts
domain modelresponsibilityrelationshipclass diagram
The lesson
Good object-oriented design starts on paper. Read the description of the process — for example how a clinic books appointments — and underline the nouns (patient, doctor, appointment) and verbs (book, cancel, reschedule). Nouns suggest classes and attributes; verbs suggest methods.
Give each class one clear responsibility. An Appointment knows its time, patient and doctor; a Schedule knows which appointments exist and refuses double bookings. If a class needs a long name with 'and' in it, split it.
Draw a simple class diagram showing which classes hold or use others, then walk through a real scenario — 'a patient cancels and rebooks' — to check the design supports it before you code.
Step by step
- Underline nouns and verbs in the clinic process description.
- List candidate classes with their attributes and methods.
- Draw the relationships between classes.
- Walk through two scenarios and adjust the design.
Practice activity
Design the classes for the clinic appointment system, present the diagram to a classmate, and revise it after walking through a cancellation scenario.
Expected result: A reviewed class diagram that supports booking, cancelling and rescheduling without double bookings.
Check your understanding
-
What does a class name containing 'and' often suggest?
Show answer
That the class has more than one responsibility and should probably be split.
Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.