"A man is known by the books he reads" Ralph Waldo Emerson

3 Books about Encapsulation in OOP [PDF]

Updated: Oct 04, 2025 | Author:
What is Encapsulation (the main idea of ​​OOP)? Listen to the word "Encapsulation". It contains the word "Сapsule". In OOP, classes are like capsules. So, the main idea of ​​OOP is that if you create a fairly large program, then the easiest way is to create it in the form of several capsules/classes. Like in the Matrix: "there are classes that control birds, classes that control trees, sunset and sunrise..."

And each class should be as independent as possible from the others. It should do its part of the job, while other classes do not see how it does it. You can make each class separately, test it and say: "Ok, This class is Ready!" And then when all the classes are ready, you run them together, they interact with each other and Magic happens.

How is encapsulation expressed specifically in code? For example, if you have a field "name" in the class Human, then by default no one sees it from the outside and this is very convenient. Because if in another class Cat also have a field "name" then no conflict will occur - these are two completely different variables.

However, classes must somehow interact with each other and therefore we cannot make them completely impenetrable. For example, one class must see the state of a field in another class (for example, if the Cat class sees that the Human class has a state "angry", then it should run away). Therefore, we still need to somehow open access to certain class variables from the outside. And the easiest way to do this is to set its access level to "public". And if you are making the program yourself, then this is enough.

But if the program is made by several people (and usually complex programs are made by several programmers - each programmer makes his own class), then you cannot do this. Because another programmer, i.e. his class, can write some crap into your variable and your class will break.

That's why Getters and Setters were invented. The idea is that the variable continues to be private, but to change it from outside - we make a special Setter method and in this Setter we usually put a bunch of conditions like: "Aha, you want to change my variable, Excuse me, who's asking? John? No, John, you can't change anything here. Bob? Okay Bob. But what do you want to write to my variable? 123? No, sorry, you can only write some string variable up to twenty characters."

And the creators of C# wanted to make these getters and setters even more convenient and came up with Properties. This is something between a variable and a method. It is written with a capital letter but has no brackets and inside it there is both a getter and a setter. And it turns out that from the outside, to access this property, we just need to write it through a period with a capital letter: Human.Name.

In addition to convenient notation, the bonus (compared to a regular public variable) is that if we want to rewrite the class, we can change its variables as we want. While this property, which is accessed by other classes from the outside, will remain the same as it was.

Here are some PDF books about Encapsulation in OOP:

The Object-oriented Thought Process
2004 by Matt A. Weisfeld


Download PDF

C++ OOP Made Simple: A Practical Guide with Examples
2025 by William E. Clark


Download PDF

C# OOP Step by Step: A Practical Guide with Examples
2025 by William E. Clark


Download PDF

See also: Top 10 eBook Organizers



How to download PDF:

1. Install Gooreader

2. Enter Book ID to the search box and press Enter

3. Click "Download Book" icon and select PDF*

* - note that for yellow books only preview pages are downloaded
Author: Maria Lin
Maria Lin, is a seasoned content writer who has contributed to numerous tech portals, including Mashable and bookrunch, as a guest author. She holds a Master's degree in Journalism from the University of California, where her research predominantly concentrated on mobile apps, software, AI and cloud services. With a deep passion for reading, Maria is particularly drawn to the intersection of technology and books, making book tech a subject of great interest to her. During her leisure time, she indulges in her love for cooking and finds solace in a good night's sleep. You can contact Maria Lin via email maria@bookrunch.com