You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: oop-essentials/03-general-principles/README.md
+11Lines changed: 11 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,13 @@ We shall first describe the principles and then relate them to the preceding cas
13
13
* The components are relatively small pieces of code that are easy to scan and understand.
14
14
* The component where a change/fix would need to be implemented is easy to identify and modifications can be made more quickly.
15
15
16
+
While the Single Responsibility Principle (SRP) traditionally applies to classes, it should also be extended to other components like functions or modules. Each function should do one thing and do it well, and each module should encapsulate a single aspect of the system's functionality. This broad application of SRP ensures that systems remain modular, easier to understand, and simpler to maintain.
17
+
18
+
In this sense, SRP can be understood as a specific application of the broader **Separation of Concerns Principle** and an alternative description
19
+
of SRP would be:
20
+
21
+
“Gather together the things that change for the same reasons. Separate those things that change for different reasons.”
22
+
16
23
2.**Open-Closed Principle**
17
24
18
25
“Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification,” i.e. entities should allow their behaviour to be extended without modifying the source code.
@@ -77,6 +84,10 @@ This is closely tied to the *principle of least surprise*, which calls for desig
77
84
Understand people as part of the system, and choose a design that matches people's expectations, experience, and mental models.
78
85
If possible, the design should prefer idiomatic language constructs over exotic, non-standard ones that aren't easily understood - even if the exotic ones may solve a problem slightly more elegantly.
79
86
87
+
# SLAP (Single Level of Abstraction Principle)
88
+
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.
90
+
80
91
# Extreme Programming (XP)
81
92
82
93
YAGNI is one of the core principles of extreme programming (aka XP), which addresses not only principles pertaining to code but also collaboration.
0 commit comments