Module null
null.py
This is a sample implementation of the 'Null Object' design
pattern.
Roughly, the goal with Null objects is to provide an 'intelligent'
replacement for the often used primitive data type None in Python or Null
(or Null pointers) in other languages. These are used for many purposes
including the important case where one member of some group of otherwise
similar elements is special for whatever reason. Most often this results
in conditional statements to distinguish between ordinary elements and
the primitive Null value.
Among the advantages of using Null objects are the following:
-
Superfluous conditional statements can be avoided by providing a
first class object alternative for the primitive value None.
-
Code readability is improved.
-
Null objects can act as a placeholder for objects with behaviour that
is not yet implemented.
-
Null objects can be replaced for any other class.
-
Null objects are very predictable at what they do.
To cope with the disadvantage of creating large numbers of passive
objects that do nothing but occupy memory space Null objects are often
combined with the Singleton pattern.
For more information use any internet search engine and look for
combinations of these words: Null, object, design and pattern.
Dinu C. Gherman, August 2001
|
|
Null
A class for implementing Null objects.
|
|
|
test()
Perform some decent tests, or rather: demos. |
|
|