Classes In OOP (Easy-Explain)

Humza Sajid
2 min readMay 18, 2022

Classes are the fundamental block in learning OOP, by using classes, developers can create structured programs with source code that can be easily modified. In this article, we will be covering the overview of classes why they’re used, and how you can use them.

I have a question for you, if I ask you to design a software that will store the following properties for 5 users (name, age, city, contact, salary).

Now you will start coding by declaring 5 variables each time for 5 users, now this is creating redundancy in your code and once you find duplication you should re-think your solution to find a better way to solve that problem.

Here in this scenario Classes can help us, HOW? Okay so let’s start Classes they are like a blueprint, once you design a blueprint you can create as many objects as you required following that particular blueprint.

Classes don’t take memory until you don’t create an object of that class.

We are now coming back to our solution for the problem of 5 users.

So you can design a Class (User) and define your properties (variables/method) and then create as many as objects you require, if you ever want to change something you will be able to make that change with a few line-of-code.

--

--

Humza Sajid

Writing easy-to-understand Web-Application Development (JS/TypeScript, React, Node) explanations for myself and others.