7

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
  • 0
    @jestdotty I don't know. I'll find out when I learn Rust. :D
  • 1
    @antigermanist I've been using it for over three decades. I wrote classes.. yeah.. once too. Hahaha.
  • 0
    I don't know about you guys but I find it already difficult enough to make sense out of all the abstraction programming and computers offer over reality. It's hard enough to make sense of that concept already, let alone all the buzzwords like 'abstract', 'data types', 'encapsulation', 'polymorphism', 'inheritance', 'is a', 'has a', 'composition', etc. Thank goodness when we understand what these mean (thanks to Software Engineering).
Add Comment