๐—ช๐—ต๐˜† ๐—ข๐—•๐—๐—˜๐—–๐—ง ๐—ข๐—ฅ๐—œ๐—˜๐—ก๐—ง๐—˜๐—— ๐—ฃ๐—ฅ๐—ข๐—š๐—ฅ๐—”๐— ๐— ๐—œ๐—ก๐—š ๐—˜๐—ซ๐—œ๐—ฆ๐—ง๐—ฆ

You build a user system. You create variables for names. You create variables for emails. You write functions for login. You write functions for logout.

This works for one user. It fails for 100 users. Data scatters. Logic scatters. Management becomes hard.

OOP solves this. It keeps data and behavior together. A user object holds its own name and its own login function. This is a self-contained unit.

State is your data. Behavior is your action. An object combines both.

You do not want to manually create 10,000 objects. You need a template. This is a class. A class is a factory. It defines what an object contains.

A class is a map. An object is the house. A class is DNA. An object is the person. The class is the definition. The object is the real entity.

OOP is not about using the class keyword. It is about responsibility. Ask yourself:

Next, we compare Factory Functions and Classes. We will look at the trade-offs.

Source: https://dev.to/ashay_tiwari_3658168ad5db/understanding-the-why-behind-software-design-oop-beyond-definitions-objects-and-classes-42b8