OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things.
So the actual basic ingredients of OOP are:
Message passing.
Encapsulation.
Dynamic binding.
You might notice that "inheritance" and classes are not considered essential. Classes are just one way of doing encapsulation, but JavaScript (and by consequence TypeScript) has other ways of achieving encapsulation that are more flexible and composable than classes, namely functions, closures and modules.
Not only that, you also used the abstract keyword to give an example of the concept of "abstraction", when that concept has nothing to do with keywords. Is like saying that the definition of "math" is the + operator.
If you're wondering how your encapsulation would look like without class:
Is a pretty common misconception to include inheritance and classes as part of OOP, but they aren't actually part of it.
The pioneer of OOP, Alan Kay, when talking about the meaning of OOP, said:
So the actual basic ingredients of OOP are:
You might notice that "inheritance" and classes are not considered essential. Classes are just one way of doing encapsulation, but JavaScript (and by consequence TypeScript) has other ways of achieving encapsulation that are more flexible and composable than classes, namely functions, closures and modules.
Not only that, you also used the
abstractkeyword to give an example of the concept of "abstraction", when that concept has nothing to do with keywords. Is like saying that the definition of "math" is the+operator.If you're wondering how your encapsulation would look like without
class:Tho is worth mentioning that for something like this, is way better to make it more functional:
Now instead of having methods locked inside a
Customerclass, we have utils that we can reuse with anything that hasFullNameon it.Cheers!
Why did you hid my comment @reaganscofield ? ... I wasn't being offensive or anything like that, I just added some clarity to your post :/