

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 5
click for more info
Not enough gems
Cost: 6 gems
1: Abstraction
incomplete
2: Abstraction vs. Encapsulation Quiz
incomplete
3: Sprint
incomplete
4: How OOP Developers Think
incomplete
5: Abstraction Practice
incomplete
This lesson's interactive features are locked, please to keep using them
Academics love to split hairs about definitions... but in practice, we're basically talking about the same thing here.
The terms "abstraction" and "encapsulation" mostly just emphasize different aspects of the same concept:
Creating good abstractions is particularly crucial when you're developing libraries for other developers to use. For example, the built-in pow function in Python is an abstraction that hides the complexity of calculating exponents.
pow isn't magic. Somewhere, code that does something like this exists and is called when you use pow:
def pow(base: int, exponent: int) -> int:
result = 1
for _ in range(exponent):
result *= base
return result