One idea
A class is the plan. An object is one real thing made from that plan, with its own state.
State is the data an object remembers between method calls. Methods should change or read that state for a clear feature reason.
Feature first
Do not start with a class named Manager, Helper, or Utils. Start with a feature sentence.
Example: “A student can add expenses and see the total split for a hostel trip.” This suggests objects like Trip and Expense because they are real parts of the feature.
Class to object
Here is a small Python example. One Trip class can create many trip objects. Each trip keeps its own expenses.
class Trip:
def __init__(self, name):
self.name = name
self.expenses = []
def add_expense(self, paid_by, amount, note):
self.expenses.append({
"paid_by": paid_by,
"amount": amount,
"note": note
})
def total_amount(self):
total = 0
for expense in self.expenses:
total += expense["amount"]
return total
manali_trip = Trip("Manali")
goa_trip = Trip("Goa")
manali_trip.add_expense("Asha", 1200, "bus booking")
goa_trip.add_expense("Ravi", 800, "scooter rent")
print(manali_trip.total_amount()) # 1200
print(goa_trip.total_amount()) # 800What state means
In this example, name and expenses are state. They belong to each Trip object.
manali_trip and goa_trip use the same class, but their state is different. That is why changing one trip does not change the other.
Shared state bug
A common bug is placing changeable state on the class instead of the object. Then all objects may accidentally share the same list.
If a list or dictionary should be different per object, create it inside the constructor.
class BadTrip:
expenses = [] # shared by every BadTrip object
def __init__(self, name):
self.name = name
class GoodTrip:
def __init__(self, name):
self.name = name
self.expenses = [] # separate list for each objectModel a small feature
Do each one yourself, then tap it to tick it off. The ticks are only a checklist for you: they are not marked or scored.
0 of 5 done
Use AI carefully
You can ask ChatGPT or Gemini: “Suggest classes, state, and methods for this feature. Keep it simple.”
Check the answer. Remove vague classes like Manager. Keep only classes that store useful state or perform a clear feature action.
Do this now
Do each one yourself, then tap it to tick it off. The ticks are only a checklist for you: they are not marked or scored.
0 of 5 done