DEV Community

Tehreem Fatima
Tehreem Fatima

Posted on

Refactoring My Book Store Management System Using OOP

Recently, I went back to one of my older Python projects, Book Store Management System, and decided to refactor it using Object-Oriented Programming (OOP).

The original version was mostly procedural. I was using functions and 2D lists to store and manage the books. When I first started converting it to OOP, I created classes, but I soon realized that simply having classes doesn't automatically make a program well-designed with OOP.

My code was still working mostly like my previous procedural programs.

So I had to step back and rethink how the data and responsibilities should be organized.

What I Changed

In the updated version, I created:

A Book class to represent individual books
A BookStore class to manage the inventory
Separate Python files for better organization
A dictionary that stores Book objects
Methods for adding books, searching, updating prices, updating stock, and displaying inventory
Input validation for different types of user input

One of the bigger changes was moving from storing book information directly in lists to working with objects.

Instead of thinking only about:

"Where should I store this data?"

I started thinking more about:

"Which object should be responsible for this data and operation?"

That was a different way of thinking for me.

What I Learned

This project made me realize that learning the syntax of classes and objects is only the beginning of OOP.

I can understand how to create a class, define attributes, create methods, and make objects, but designing a program around objects is a different challenge.

I still need more practice with:

Designing classes
Deciding class responsibilities
Working with objects
Understanding relationships between objects
Structuring larger programs using OOP

The refactoring was a little difficult for me, especially because most of my previous projects were procedural. But that difficulty was useful because it showed me exactly where I need more practice.

What's Next?

I don't consider this project the end of my OOP learning.

I'll continue practicing OOP through more projects and gradually work on designing better class structures instead of simply converting procedural code into classes.

For now, I'm happy with the progress and with being able to recognize where I still need improvement.

GitHub Repository:

GitHub logo tehreem-fatima-dev / Book_Store_Management_System

Python-based book inventory management system with search, updates, inventory tracking, and summary generation.

Book Store Management System v2.0

A menu-driven Python application for managing a bookstore inventory. This version is a refactored OOP-based implementation of the original Book Store Management System. The system allows users to add books, search the inventory, update book prices and stock quantities, and display the complete inventory.

Features

  • Add new books
  • Prevent duplicate book entries
  • Search books by title
  • Search books by author
  • Case-insensitive search
  • Partial keyword search
  • Update book prices
  • Update stock quantities
  • Display complete inventory
  • Input validation for prices, stock quantities, and menu options
  • Separate modules for book and bookstore functionality

OOP Concepts Used

  • Classes and objects
  • __init__() constructor
  • Instance attributes
  • Instance methods
  • self
  • Passing objects as arguments
  • Object interaction
  • Encapsulation of bookstore data

Data Structure

  • A dictionary is used to store the inventory.
  • Each dictionary value is a Book object rather than a nested dictionary.
  • The book name is used as the dictionary key for…

You can also find my other Python projects on my GitHub profile:

GitHub: https://github.com/tehreem-fatima-dev

Top comments (0)