Bootcamp

From idea to product, one lesson at a time. To submit your story: https://tinyurl.com/bootspub1

Member-only story

Encapsulation in OOPs

Devrim Ozcay
Bootcamp
Published in
6 min readOct 23, 2022

--

Hello, first of all, if you have read my articles about OOP. You will see that I have given the OOP concepts one by one and in an explanatory way. If you ask why I am doing such a thing, because these are all important concepts, concepts that a software developer should know. In this article, I wrote encapsulation and I will try to convey all of them in detail. I wish you good reading in advance :).

We talk about privacy all the time in our daily lives. We hide events that we cannot tell anyone about. Sometimes we try to tell a secret to a friend. This is no longer a secret. The software world is like that. According to object-oriented programming languages, everything actually consists of objects, these objects have some properties. As with humans, some characteristics are shared with someone else. When a person says something to another person, it is as if he has transferred the words he has hidden or hidden to another person. If everything in software is an object, there must be communication between objects. How that happens? Let’s see together :)

What is Encapsulation

Encapsulation is the use of data by keeping it together in Object Oriented Programming language. It connects code and data by manipulating them with each other. Also, encapsulation code can be thought of as a shield that prevents access to data. Encapsulation stops data from being visible to the code and uses the necessary methods to gain access to them. These methods are setter and getter methods. These methods are the most popular methods of revealing data hidden by encapsulation to the outside world. Now let’s make it even more detailed :).

1. Encapsulation At The Basic Level

A basic example of encapsulation is the transfer of data defined as private in one class to other classes with setter and getter methods. For example, Berk slept with the lamp on. Finding the lamp on, Ali decides how to turn the lamp off without going to the room with a simple code after a short thought.

--

--

Bootcamp
Bootcamp

Published in Bootcamp

From idea to product, one lesson at a time. To submit your story: https://tinyurl.com/bootspub1

No responses yet