From Functions to Classes: My Journey Back to OOP in JavaScript
23 Jul 2025
Hey devs đ,
Let me take you on a little time-travel.
Back in college somewhere around my second year. I was introduced to the magical world of Object-Oriented Programming. You know, the good old class
, object
, inheritance
, and the legendary "Evergreen Library Management System" project. I was into it. I even tried implementing OOP concepts in small Java projects, and it felt like I had finally unlocked the Matrix.
But then...
I discovered web development.
HTML was welcoming. CSS was confusing. JavaScript? it was love at first script. â¤ď¸
And thatâs where I started shifting. Slowly away from OOP. I mean, JavaScript didnât force me into OOP, and most of the tutorials, libraries, and frameworks I came across were all in on functional programming. It felt simple, elegant, and honestly, it just worked.
I started building projects with my friend. From basic websites to full stack applications. Life was good.
But then came my internship and suddenly, I was inside an enterprise-grade application, and reality hits. I think thatâs enough letâs focus on the context now
1. The Functional World We Inherited
To be honest JavaScript has a weird relationship with OOP.
It supports it, but doesnât enforce it. And most libraries especially the older ones lean heavily toward functional programming.
Youâve probably seen it:
- Reusable functions everywhere
- Pure functions with no side effects
- Higher-order functions, composition and lot more.
And to be clear: functional programming is awesome. Itâs powerful and elegant.
But when I started looking at large-scale applications during my internship. Every file was structured around classes, inheritance, design patterns, and I was like, âWait, is this JavaScript... or did I accidentally open a Java repo?â
2. The Mindset We All Had: âOOP? that is over engineeredâ
When you're solving real-world problems with JavaScript, you might think:
OOP? Nah bro, Iâll just slap some functions together and hope for the best.
I get it. That mindset works fine for:
- Small projects
- Side hustles
- Personal portfolios
But in enterprise apps, it starts to show cracks.
You find yourself:
- Debugging deep callback hells
- Juggling utils with unclear responsibilities
- Reading code that feels like spaghetti... but uglier
Thatâs when I realized structure, boundaries, and design principles matter.
I thought my code was modular until I tried to change one thing and 42 files broke.
3. So... Do We Need OOP in JavaScript?
Short answer? Not always.
Long answer? Youâll thank yourself for knowing it.
3.1. It Sharpens Your Thinking
OOP helped me think in terms of:
- Responsibility (Who should do what?)
- Encapsulation (What should be exposed?)
- Reusability (How can I write it once and use it well?)
Suddenly, I wasnât just writing code I was designing systems.
OOP turned my functions from anxious teenagers into responsible adults.
3.2. It Helps You Decode Complex Codebases
Ever opened a third-party library and felt like you were reading ancient alien scripts?
Well, OOP knowledge helps.
Understanding concepts like:
- Composition vs Inheritance
- SOLID principles
- Patterns like Factory, Singleton, Strategy
3.3. But Letâs Not Get Carried Away
I still stand by this:
Donât over-complicate simple things.
If a function is just formatting a date? Keep it functional.
But when you're building a system that involves:
- Multiple layers of logic
- Shared responsibilities
- Scalability concerns
Then thinking in OOP terms will save you hours of debugging and countless âWhy did I write this?â moments.
4. Me as a TS Dev Today
I like trying new patterns. I love tweaking things. I enjoy the freedom JS/TS gives me.
These days:
- I use functional code for utilities, helpers, and simple logic.
- I use OOP when I need structure, abstraction, and clarity in larger systems.
- And most importantly I choose based on what the situation demands, not whatâs trendy.
Itâs not about âFunctional vs OOPâ.
Itâs about knowing both, and using them wisely.
5. Finally, What Iâm Really Trying to Say...
If youâre a JavaScript dev avoiding OOP because it feels like overkill trust me, I get it.
But hereâs a pro tip from someone who took the scenic route:
đ Even basic OOP understanding will level up your ability to read, write, and reason about code especially in large teams or codebases.
And donât worry you donât have to give up your arrow functions or map/filter/reduce
.
You just need to add another tool to your belt.
So go ahead earn about class
, constructor
, extends
, super
, and all that jazz.
Even better: wait for my upcoming blogs. I promise it wonât be boring đ
Functional and OOP arenât enemies. Theyâre like Batman and Superman. Annoy each other, but stronger together.
Catch you in the next post đ
Thanks again for reading!
Feel free to share this post with fellow devs â and if youâve got feedback, ideas, or questions, Iâd love to hear from you.