Skip to content

Commit b71b988

Browse files
committed
Copy edit for NullObject readme
1 parent 37cdbd6 commit b71b988

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

Behavioral/NullObject/README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22

33
## Purpose
44

5-
NullOutput is a example of NullObject pattern. It is not formally a Design Pattern by the GoF but it's a schema which appears frequently enough to
6-
be a pattern. Furthermore it is a really good pattern in my opinion:
5+
NullObject is not a GoF design pattern but a schema which appears frequently enough to be considered a pattern. It has the following benefits:
76

8-
* the code in the client is simple
9-
* it reduces the chance of null pointer exception
10-
* less "if" => less test cases
7+
* Client code is simplified
8+
* Reduces the chance of null pointer exceptions
9+
* Fewer conditionals require less test cases
1110

12-
Every time you have a method which returns an object or null, you should return an object or a `NullObject`. With NullObject, you don't need
13-
a statement like `if (!is_null($obj)) { $obj->callSomething(); }` anymore.
11+
Methods that return an object or null should instead return an object or `NullObject`. `NullObject`s simplify boilerplate code such as `if (!is_null($obj)) { $obj->callSomething(); }` to just `$obj->callSomething();` by eliminating the conditional check in client code.
1412

1513
## Examples
1614

@@ -21,4 +19,4 @@ a statement like `if (!is_null($obj)) { $obj->callSomething(); }` anymore.
2119

2220
## UML Diagram
2321

24-
![Alt NullObject UML Diagram](uml/uml.png)
22+
![Alt NullObject UML Diagram](uml/uml.png)

0 commit comments

Comments
 (0)