Skip to content

Commit 557046d

Browse files
committed
Add a section about single level of abstraction principle to general-principles
1 parent 6f55b46 commit 557046d

File tree

1 file changed

+3
-1
lines changed
  • oop-essentials/03-general-principles

1 file changed

+3
-1
lines changed

oop-essentials/03-general-principles/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ If possible, the design should prefer idiomatic language constructs over exotic,
8686

8787
# SLAP (Single Level of Abstraction Principle)
8888

89-
The **Single Level of Abstraction Principle** states, that a function should either be low-level function itself (think of a pure procedural code snippet like a for loop) or should only call other (possible low-level) functions. One should avoid a mixture of these different levels.
89+
The **Single Level of Abstraction Principle** (SLAP) states that a function should operate at a single level of abstraction. Specifically, a function should either perform a high-level operation by calling other functions or handle low-level operations directly (e.g., loops, conditionals, or simple calculations), but not mix these levels within the same function.
90+
91+
Adhering to SLAP ensures that functions are cohesive and focused, making them easier to understand and maintain. When a function strictly adheres to SLAP, it either orchestrates higher-level processes by delegating tasks to other functions or directly handles low-level details. This separation allows developers to comprehend the function's purpose quickly, without being distracted by unrelated details, which can increase the readability a lot.
9092

9193
# Extreme Programming (XP)
9294

0 commit comments

Comments
 (0)