From 1cd0cb89973174ec2fa177081b50ab34497a07c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilkka=20Sepp=C3=A4l=C3=A4?= Date: Wed, 4 Mar 2015 23:05:55 +0200 Subject: [PATCH] Added Null Object pattern description. --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index d484808b7..9ebc423ac 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ * [Model-View-Presenter](#model-view-presenter) * [Double Checked Locking](#double-checked-locking) * [Servant](#servant) +* [Null Object](#null-object) ## Abstract Factory [↑](#list-of-design-patterns) **Intent:** Provide an interface for creating families of related or dependent objects without specifying their concrete classes. @@ -382,6 +383,14 @@ **Applicability:** Use the Servant pattern when * When we want some objects to perform a common action and don't want to define this action as a method in every class. +## Null Object [↑](#list-of-design-patterns) +**Intent:** Null Object is used instead of null values to simplify algorithm and avoid explicit null checking. + +![alt text](https://github.com/iluwatar/java-design-patterns/blob/master/null-object/etc/test.png "Null Object") + +**Applicability:** Use the Null Object pattern when +* You want to avoid explicit null checks and keep algorithm elegant and easy to read. + # Frequently asked questions