6

Story:
Useful lesson I learned in a JavaScript book:

"Classes are abstract data types in the sense that they are a layer around the complexity (encapsulation). Their singular nature allows them to be reused without being rewritten everywhere.

A good analogy is thinking of classes as appliances; the complex circuitry and components that an appliance comprises of are made by different people than the abstract shell around these components, of which (another) team only needs to know which buttons to access which parts.
A class abstracts away the internal complexity (components) and only exposes a public interface (the buttons) that the user (yet another group, comparable to the consumer of the class) is going to use."

It reminds me of how Google uses the Facade pattern to only expose the search box and the button as its public interface and all the complex architecture is hidden away.

This helped clarify classes better for me.

Comments
  • 0
    yeah but how is that encapsulation exist in rust tho
  • 0
    I've been using javascript for 7 years. I think I wrote class once.

    OOP is quite old already
Add Comment