Skip to main content

Command Palette

Search for a command to run...

How I Built Simple Library and Banking Systems Using OOP in Python.

Practical OOP: Bridging the Gap Between Syntax and System.

Updated
4 min readView as Markdown
How I Built Simple Library and Banking Systems Using OOP in Python.
D
I’m building my career in tech from the ground up — no shortcuts, no degree, just discipline and deliberate practice. Coding Through Chaos is my documentation of learning backend systems, problem-solving, and software engineering fundamentals. I break down what I learn, question assumptions, and refine my thinking publicly. I believe complexity is inevitable — clarity is engineered.

After learning the core ideas and fundamentals of Object-Oriented Programming, I decided to build working systems based on it to gain a more practical understanding.

As a developer in progress, I realized I need to live OOP rather than just memorize it. Theory alone doesn’t give the experience of how systems actually work. Real understanding comes from implementing what you learn.

So instead of stopping at concepts, I built two simple systems—a library system and a banking system—to see how OOP works in real scenarios.

Let’s dive into what I built and what I learned from it.

Why I Built These Systems

The main reason I built these systems was to test my understanding and see how I could apply concepts like abstraction, encapsulation, inheritance, and polymorphism in real code.

In tutorials, everything looks smooth and straightforward. But when I sat down to build it on my own, I ran into many errors. That process of debugging my code step by step is what gave me the real learning.

Project 1: The Library Management System

This system allows for adding, borrowing, and returning books.

class Book:
    def __init__(self, title, copies):
        self.title = title
        self._copies = copies

    def add(self, copies):
        if copies <= 0:
            raise ValueError('please enter a valid value')
        self._copies += copies

    def borrow(self, copies):
        if copies <= 0:
            raise ValueError('invalid number of copies')
        if copies > self._copies:
            raise ValueError(f'{copies} not available for this book {self.title}')
        self._copies -= copies   

    def return_book(self, copies):
        if copies <= 0:
            raise ValueError('you did not return a book')
        self._copies += copies

    def available(self):
        return self._copies


class Library:
    def __init__(self):
        self.book = {}

    def addingbooks(self, title, copies):
        self.book[title] = Book(title, copies)

    def borrowed_books(self, title, copies):
        if title not in self.book:
            raise ValueError(f"sorry! {title} book is not available right now")
        self.book[title].borrow(copies)   

    def returned_book(self, title, copies):
        if title not in self.book:
            raise ValueError(f"This {title} does not belong to this library")
        self.book[title].return_book(copies)  

    def available_book(self):
        for items in self.book.values():
           print(f"{items.title} - {items.available()} copies available")


# Usage
item_details = Library()
item_details.addingbooks("python", 7)
item_details.addingbooks("java", 7)
item_details.addingbooks("react", 12)

item_details.borrowed_books("python", 6)
item_details.returned_book("python", 3)

item_details.available_book()

This project helped me understand how to organize code using classes. Instead of handling everything separately, each book became an object with its own data and actions. The Library class manages all the books in one place.

While building this, I made mistakes like wrong inputs and logic errors. Fixing those step by step helped me understand OOP much better than just reading about it.

Project 2: The Banking System

This system allows users to create an account, deposit an amount, withdraw an amount, and check their balance.

class BankAccount:
    def __init__(self, name, balance):
        self.name = name
        self._balance = balance

    def create_account(self):
        account_number = random.randint(1000, 99999)
        print(f"Account created for {self.name} with Account Number: {account_number}")
        return account_number

    def deposit(self, amount):
        if amount <= 0:
            print("Invalid deposit amount")
            return
        
        self._balance += amount
        print(f"Deposited {amount}. Available balance: {self._balance}")

    def withdraw(self, amount):
        if amount <= 0:
            print("Invalid withdrawal amount")
            return
        
        if amount > self._balance:
            print("Insufficient balance")
            return
        
        self._balance -= amount
        print(f"Withdrawn {amount}. Available balance: {self._balance}")

    def available_balance(self):
        return self._balance


# Usage
customer1 = BankAccount("Subash", 12000)

customer1.create_account()
customer1.deposit(200)
customer1.withdraw(200)

print(f"Available balance: {customer1.available_balance()}")

What I Learned From Building These Projects

These two projects tested the knowledge I gained from OOP concepts. They helped me understand how to protect data (like a bank balance) using encapsulation, and how classes and objects make code much more organized.

I also tried to apply real-world logic in my code, like how a library or banking system actually operates.

These are not massive or overly complex systems, but they work. And more importantly—I built them myself.