Amy Blankenship
Nov 25, 2022

--

https://en.wikipedia.org/wiki/Encapsulation_(computer_programming)

In object-oriented programming (OOP), encapsulation refers to the bundling of data with the methods that operate on that data, or the restricting of direct access to some of an object's components.[1] Encapsulation is used to hide the values or state of a structured data object inside a class, preventing direct access to them by clients in a way that could expose hidden implementation details or violate state invariance maintained by the methods.

The restricting of direct access is what prevents unexpected bugs. You could choose to call that isolation, or not. But it's what encapsulation is for.

--

--

Amy Blankenship
Amy Blankenship

Written by Amy Blankenship

Full Stack developer at fintech company. I mainly write about React, Javascript, Typescript, and testing.

Responses (1)