Modelling and persistence
What is object-oriented analysis?
On this page
Analysis identifies domain concepts, rules and responsibilities. In a lending system, interview staff about what happens when a copy is returned after closing time. The answer reveals rules about dates and fees. Drawing a class called Loan is less informative until those rules are understood.
Worked example
Pythonfrom datetime import date, datetime, time, timedelta
# Assumed lending rule: after closing, credit the following date.
def credited_date(returned):
after_close = returned.time() >= time(18)
return returned.date() + timedelta(days=int(after_close))
assert credited_date(datetime(2026, 6, 1, 17, 59)) == date(2026, 6, 1)
assert credited_date(datetime(2026, 6, 1, 18, 0)) == date(2026, 6, 2)Explore class relationships in the OOP Playground