Special Case

A generalization of NullObject.

Represent special values with an object of distinguished class.

For example:

  Date (or Timestamp) -> Past & Future - special cases that are before (after) every other date.

Date (or Timestamp) -> Now - continuously updates

Money -> Zero - an object representing no monetary value

Combining the date special cases with TimeInterval? results in some interesting possibilities.


SpecialCase is really a SpecialCase of ObjectOriented programming in general just applied to some well known base types, isn't it? Consider Boolean in SmallTalk. True and False are just special cases.


See also http://www.martinfowler.com/eaaCatalog/specialCase.html (Part of PatternsOfEnterpriseApplicationArchitecture catalog)

CategoryPattern


EditText of this page (last edited April 6, 2006) or FindPage with title or text search