this post was submitted on 02 Feb 2024
51 points (89.2% liked)

Programming

16975 readers
1288 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 1 year ago
MODERATORS
 

There are so many definitions of OOP out there, varying between different books, documentation and articles.

What really defines OOP?

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 3 points 7 months ago* (last edited 7 months ago) (1 children)

What kind of different defintions have you came across?

In Essence, OOP: you describe with your code Classes and how those classed Objects interact with each other. Classes can be inherited from other Classes and or implement Interfaces (Interface, Traits, Protocol) so you know how derived classes can be interacted with even though you don't know the concrete class until runtime execution.

The tradeoff would be the stringent nature of OOP: you need to have Objects, otherwise it's just functional/procedural programming with extra steps.

[–] [email protected] 1 points 7 months ago (1 children)

Javascript is generally considered OOP, but classes weren't widely available till 2017.

Inheritance isn't fundamental to OOP, and neither are interfaces. You can have a duck- typed OOP language without inheritance, although I don't know of any off the top of my head.

Honestly, the more fundamental thing about OOP is that it's a programming style built around objects. Sometimes OO languages are class based, or duck typing based, etc. But you'll always have your data carrying around it's behavior at runtime.

[–] [email protected] 1 points 7 months ago

JavaScript has been OOP since I can remember due to its prototypal nature. Change something on an inherited prototype, and every descendant also get those changes. And "classes" is just syntax sugar for that prototype mechanism.