“Encapsulation” Réponses codées

encapsulation

What is encapsulation?
Encapsulation protects your code by controlling the ways values are accessed and
changed, so that your code is only used as explicitly designed. Like
abstraction,encapsulation places a layer of separation between the underlying 
complexity of your code and the programmers who might be accessing it.
(learn more at link below)
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
glowst0ne

encapsulation

In general, encapsulation is a process of wrapping similar code in one place.

Encapsulation is one of the key features of object-oriented programming. It involves the bundling of data members and functions inside a single class.
Bundling similar data members and functions inside a class together also helps in data hiding.

Note: People often consider encapsulation as data hiding, but that's not entirely true.
Encapsulation refers to the bundling of related fields and methods together. This can be used to achieve data hiding. Encapsulation in itself is not data hiding.
Usama.dev

Encapsulation

class Account:

    def __init__(self):
        self._transactions = [] # the "_" prefix means treat this as private
        
    def deposit(self, amount):
        self._transactions.append(amount)
Super Shark

Encapsulation

class Account:

    def __init__(self):
        self._transactions = [] # the "_" prefix means treat this as private
        
    def deposit(self, amount):
        self._transactions.append(amount)
Super Shark

Encapsulation

class Account:

    def __init__(self):
        self._transactions = [] # the "_" prefix means treat this as private
        
    def deposit(self, amount):
        self._transactions.append(amount)
Super Shark

Réponses similaires à “Encapsulation”

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code