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: null-object/README.md
+137
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,143 @@ implements the expected interface, but whose method body is empty. The
18
18
advantage of this approach over a working default implementation is that a Null
19
19
Object is very predictable and has no side effects: it does nothing.
20
20
21
+
## Explanation
22
+
23
+
Real world example
24
+
25
+
> We are building a binary tree from nodes. There are ordinary nodes and "empty" nodes. Traversing the tree normally should not cause errors, so we use null object pattern where necessary.
> In object-oriented computer programming, a null object is an object with no referenced value or with defined neutral ("null") behavior. The null object design pattern describes the uses of such objects and their behavior (or lack thereof).
34
+
35
+
**Programmatic Example**
36
+
37
+
Here's the definitions for node interface and its implementations.
0 commit comments