Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a recognized pattern for useless objects that implement an interface?

For example, (although it's not an interface) the Stream class in .NET has an implementation provided by Stream.Null which simply discards the data. PowerShell has Out-Null.

In applications I've developed, I've often found it useful to implement an interface IFoo with a default implementation NullFoo or similar when it is preferable to have a useless implementation rather than not passing an object at all.

My question is how should I refer to this practice in documenting or explaining an architecture? Is there a recognized name or GoF/Fowler design pattern for this?

like image 682
Josh Avatar asked Jun 03 '09 14:06

Josh


1 Answers

This pattern is often refered as "NullObject" : http://en.wikipedia.org/wiki/Null_Object_pattern

like image 122
Guillaume Avatar answered Nov 01 '22 20:11

Guillaume