it s about abstraction

preview_player
Показать описание
understanding abstraction in programming

what is abstraction?

abstraction is a fundamental concept in object-oriented programming (oop) that involves hiding the complex reality while exposing only the necessary parts. it simplifies the design of software by allowing the programmer to focus on the interactions between different components rather than the intricate details of each component.

why use abstraction?

1. **simplification**: it reduces complexity by hiding unnecessary details.
2. **modularity**: it allows for the separation of concerns, making code easier to maintain and understand.
3. **reusability**: abstract components can be reused across different parts of a program or in different projects.
4. **flexibility**: changes in one part of the system can be made with minimal impact on other parts.

types of abstraction

1. **data abstraction**: hiding the details of data implementation (e.g., using classes).
2. **control abstraction**: hiding the details of control flow (e.g., using functions or methods).

code example

let’s illustrate abstraction with a simple example in python. we will create a `vehicle` class that abstracts the idea of a vehicle, encapsulating its properties and behaviors without exposing the inner workings.

```python
from abc import abc, abstractmethod

abstract class
class vehicle(abc):
@abstractmethod
def start_engine(self):
pass

@abstractmethod
def stop_engine(self):
pass

@abstractmethod
def drive(self):
pass

concrete class
class car(vehicle):
def __init__(self, make, model):

def start_engine(self):

def stop_engine(self):

def drive(self):
if ...

#Abstraction #ArtConcepts #windows
abstraction
concepts
theory
representation
simplification
essence
generalization
visualization
model
design
philosophy
interpretation
creativity
analysis
structure
Рекомендации по теме