Abstraction
Learn how abstraction hides implementation details and focuses on what an object does in BornomalaScript.
Abstraction
Abstraction means showing only the important details and hiding the rest.
When you use abstraction, you focus on what something does instead of how every step is implemented.
Why Abstraction Matters
Abstraction makes code easier to read and easier to use.
For example, when you press a button in an app, you care about the action it performs, not the internal steps behind it.
That same idea appears in programming objects and methods.
Simple Example
Imagine a printer object.
You may only want to call something like print(), even though the printer internally handles paper, ink, and formatting.
The important part is the action, not the hidden details.
Conceptual Example
dhoro printer = {
print: kaj(text) {
lekho(text)
}
}
printer.print("Shagotom")
The user of the object only needs to know that print exists.
How It Works
Abstraction helps you:
- hide complex logic
- expose simple methods
- reduce confusion for users of your code
- make programs easier to maintain
Step-by-Step Breakdown
- Decide what the object should do
- Hide the unnecessary internal logic
- Expose a simple method or interface
- Let the rest of the program use that simple interface
Common Mistakes
Beginners often make these mistakes:
- exposing too many internal details
- making the interface harder than the problem
- mixing the action and the implementation in one place
Practice Task
Try thinking about abstraction for:
- A login system
- A file-saving action
- A music player
For each one, ask yourself: what should the user of the object see, and what should stay hidden?
Quick Checklist
Before moving on, make sure you can:
- explain abstraction in simple words
- describe the difference between what something does and how it does it
- identify one example where hiding complexity helps
If yes, you are ready for inheritance.