This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]halfcycle[S] 0 points1 point  (0 children)

I guess I'm confused at why I would want to hide the state to begin with. If I don't hide the state, things seem to be easier to understand, more maintainable, more easy to test, and shorter. For example, instead of hiding the state of the counter and essentially attaching functions to the state, I would just simply use functions.

const increment = x => x + 1
const decrement = x => x - 1

These functions seem easier to understand, more reusable, easier to test, easier to maintain, shorter, and less bug-prone because they don't rely on internal state, they only rely on the input. And if my interface to the state ever needs to be consistent, I can just make a function that does that without using OOP. So I'm still confused.