Skip to content

Improve Abstraction Explanation and Replace Encapsulation-Based Example with True Abstraction Example#3

Open
AbdullahProjects wants to merge 2 commits intojafari-dev:masterfrom
AbdullahProjects:master
Open

Improve Abstraction Explanation and Replace Encapsulation-Based Example with True Abstraction Example#3
AbdullahProjects wants to merge 2 commits intojafari-dev:masterfrom
AbdullahProjects:master

Conversation

@AbdullahProjects
Copy link
Copy Markdown

Hy @jafari-dev!
First of all, thank you for maintaining this repository! I really appreciate the effort put into making these OOP concepts clear. I noticed the current abstraction example could be improved to better reflect true abstraction, so I’ve made some updates to enhance clarity and provide a more practical example.

Pull Request Explanation:

The current Car example explains abstraction conceptually, but the implementation mainly demonstrates encapsulation (hiding data using private fields) rather than true abstraction.

While the example hides internal state (speed), it does not:

  • Define a behavioral contract
  • Use an abstract class or interface

To better reflect the concept of abstraction, the example has been updated to include an abstract base class with multiple concrete implementations.

✅ Changes Made

  • Replaced the concrete Car class example with a proper abstraction example.
  • Introduced an abstract class (Vehicle) to define a behavior contract.
  • Added multiple implementations (Car, Bike).
  • Added explanation of why this demonstrates abstraction properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant