0
0
LLDsystem_design~3 mins

Why User, Group, Expense classes in LLD? - Purpose & Use Cases

Choose your learning style9 modes available
The Big Idea

What if you could stop the headache of messy shared bills with just a few smart classes?

The Scenario

Imagine you are trying to track who owes what in a group of friends manually using just notes or spreadsheets.

You write down each person's name, the groups they belong to, and every expense they make. It quickly becomes a mess.

The Problem

Manually managing users, groups, and expenses is slow and confusing.

It's easy to forget who paid for what or how to split costs fairly.

Errors happen often, and updating information takes too much time.

The Solution

Using User, Group, and Expense classes organizes this data clearly.

Each user is an object, groups hold users, and expenses link to both.

This structure makes tracking, updating, and calculating shares simple and reliable.

Before vs After
Before
users = ['Alice', 'Bob']
groups = {'Trip': ['Alice', 'Bob']}
expenses = [('Alice', 'Trip', 100)]
After
class User:
    pass
class Group:
    pass
class Expense:
    pass
What It Enables

It enables building clear, scalable systems to manage shared expenses without confusion or errors.

Real Life Example

Apps like Splitwise use these classes to help friends split bills easily and fairly.

Key Takeaways

Manual tracking is error-prone and slow.

Classes organize users, groups, and expenses logically.

This design makes managing shared costs easy and scalable.