Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfc55b9b

Browse files
author
Dominik Liebler
committed
Merge pull requestDesignPatternsPHP#109 from Bilge/patch-2
Copy edit for NullObject readme
2 parents37cdbd6 +b71b988 commitfc55b9b

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 codein the clientissimple
9-
*it reducesthe chance of null pointerexception
10-
*less "if" => less test cases
7+
*Client code issimplified
8+
*Reducesthe chance of null pointerexceptions
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)

[8]ページ先頭

©2009-2025 Movatter.jp