I've been messing around with Lua for about two weeks, tackling challenges on platforms like Leetcode and Advent of Code, and I also spent a year learning C in school. My problem is that I've never quite seen the practical utility of Object Oriented Programming (OOP) in action. I know it has its merits—otherwise it wouldn't be so widely adopted—but I'm curious about the actual uses and advantages it offers beyond the usual talking points like modularity and ease of editing. Can anyone point me to some books or videos that dive deeper into these concepts? Additionally, some exercises that showcase where OOP shines would be super helpful!
4 Answers
OOP really shines when dealing with complex data structures, especially in larger systems where data and behavior need to be maintained as a state. For example, when you think about users in a system, you can model a User as a specific type of Person. It just makes logical sense when things map directly to real-world objects.
If you're mostly doing small projects, you might not see OOP's value at first. Its true benefits come into play when you're using an OOP-centric language and working on larger applications where you have multiple instances of each object. That's when the modular structure starts saving you a lot of hassle.
OOP is everywhere! Most websites utilize OOP concepts, especially when it comes to structuring their DOM. Plus, both iOS and Android rely heavily on OOP principles. It's estimated that a significant majority (60-80%) of software utilizes OOP, so once you get into it, you’ll see just how prevalent it is.
From my experience, OOP helps abstract the complexities of coding by allowing you to bundle state and operations into classes. For example, the SOLID principles guide you in structuring your classes such that if you need to make changes, you minimize impact on the entire codebase. Instead of having everything in one giant class, you break it down—making it easier to manage and update.
That makes sense! What about polymorphism? How does that fit into this picture?