Finding Objects in the Problem Domain
The first step in OO analysis is identifying the objects and classes that exist in your problem domain. This means reading through requirements, talking to stakeholders, and looking at the real-world processes you're trying to model. Objects are the "nouns" in your system β the things that have state and behavior.
A good starting point is to scan requirements documents for nouns. Nouns often represent potential classes, while verbs often represent operations. But not every noun becomes a class β you need to filter for things that are relevant to the system and have distinct behavior or state.
Requirements Example:
"Students register for courses. Each course has a maximum capacity.
Instructors assign grades. The system sends email notifications."
Nouns β Potential Classes:
Student β (has state: name, ID; behavior: register, drop)
Course β (has state: capacity, schedule; behavior: enroll, cancel)
Instructor β (has state: name, department; behavior: assign grade)
Grade β (maybe an attribute, not a full class)
System β (too vague)
Email β (implementation detail, not a domain concept)
Verbs β Potential Operations:
register β Student.register(course)
assign β Instructor.assignGrade(student, grade)
send β NotificationService.sendEmail()
Techniques for Identifying Objects
Several techniques help you systematically discover objects and classes:
1. Noun Phrase Analysis
βββββββββββββββββββββ
Scan requirements for noun phrases.
"A patient books an appointment with a doctor"
β Patient, Appointment, Doctor
2. Event Analysis
ββββββββββββββ
List events that occur in the system.
"A customer places an order, receives confirmation,
and can track shipment"
β Order, Confirmation, Shipment
3. Responsibility Analysis
ββββββββββββββββββββββββ
Ask: "What responsibilities does the system have?"
"The system must manage inventory, process payments,
and generate reports"
β Inventory, PaymentProcessor, ReportGenerator
4. CRC Cards (Class-Responsibility-Collaborator)
ββββββββββββββββββββββββββββββββββββββββββββββ
Create index cards with:
β’ Class name
β’ Responsibilities (what it does)
β’ Collaborators (what it works with)
βββββββββββββββββββββββββββββββββββββββ
β Class: Order β
βββββββββββββββββββββββββββββββββββββββ€
β Responsibilities: β
β β’ Track order status β
β β’ Calculate total price β
β β’ Apply discounts β
β β’ Generate invoice β
β β
β Collaborators: β
β β’ Customer β
β β’ OrderItem β
β β’ PaymentProcessor β
β β’ InventoryManager β
βββββββββββββββββββββββββββββββββββββββ
Filtering Candidates
Not every noun becomes a class. Apply these filters to decide what stays:
Keep as a Class if:
β It has attributes that need to be stored
β It has behavior (methods) beyond simple getters/setters
β It represents a real-world entity or concept
β Multiple instances will exist
β It interacts with other objects
Discard if:
β It's a primitive value (just use a string or number)
β It's a duplicate of an existing class
β It has no behavior and few attributes (consider making it an attribute)
β It's an implementation detail (database connection, logger)
β It's a verb (that's a method, not a class)
For example, in a library system, "book title" is just a string attribute of Book β not its own class. But "Book" is definitely a class because it has state (title, author, ISBN, availability) and behavior (checkOut, return, reserve).
Example: Hospital Management System
Let's walk through identifying objects for a hospital system:
Problem Statement:
"The hospital manages patients, doctors, and appointments.
Patients have medical records. Doctors work in departments.
The system schedules surgeries and manages billing."
Step 1: Extract nouns
Patient, Doctor, Appointment, Medical Record, Department,
Surgery, Bill, Hospital, System
Step 2: Filter and refine
β Patient β has records, books appointments
β Doctor β has specialties, works in departments
β Appointment β connects patient and doctor
β MedicalRecord β stores patient history
β Department β organizes doctors and rooms
β Surgery β scheduled procedure with team
β Bill β tracks costs and payments
β Hospital β too broad (the whole system, not a class)
β System β too vague
Step 3: Define relationships
Patient ββhasβββΆ MedicalRecord
Doctor ββbelongs toβββΆ Department
Appointment ββinvolvesβββΆ Patient, Doctor
Surgery ββscheduled byβββΆ Doctor, involvesβββΆ Patient
Bill ββgenerated forβββΆ Patient, includesβββΆ Services
Pitfalls to Avoid
Common mistakes when identifying objects:
1. God Object
ββββββββββββ
Making one class do everything.
"System" or "Manager" that handles all operations.
β Break it into smaller, focused classes.
2. Anemic Domain Model
ββββββββββββββββββββ
Classes that are just data containers with no behavior.
All logic lives in service classes.
β Move behavior into the objects that own the data.
3. Analysis Paralysis
ββββββββββββββββββββ
Spending too much time trying to find the "perfect" model.
β Start with a good-enough model and refine as you learn more.
4. Over-engineering
ββββββββββββββββββ
Creating classes for every little concept.
β Keep it simple. Only create classes that add clear value.