Small Objects Promote Encapsulation

--

Hiding implementation involves abstracting data manipulation, not adding functions between variables.

Small objects encapsulate specific behaviors and break down complex tasks into manageable pieces.

Encapsulation refers to grouping data with the methods that manipulate that data. Encapsulation conceals an object’s information, represented by its data or internal state. This is important because it increases coupling when objects access each other’s internal data.

It’s important to avoid asking objects for information and perform a function for them.

Command objects to do what they need to do. Each object handles its part of the domain and should tell the next object what to do.

Encapsulation should remove the ability to add if statements, forcing us to use commands instead of queries.

[¹]: Practical Object-Oriented Design: An Agile Primer Using Ruby

--

--

Rafael A. George Duval
Rafael A. George Duval

Written by Rafael A. George Duval

✍🏼 Building a Solo Digital Media Company 🧪 Snippets of Text [https://snippetsoftext.substack.com/subscribe]

No responses yet