Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Null Object Pattern
Simplicity in doing nothing
What is a Design Pattern?
● A reusable solution to a common problem
● Kent Beck and Ward Cunningham applied to
computer sc...
Null Object Pattern
● Categorized as behavioral pattern
● Similar to the strategy, or state pattern
● Polymorphism
● null ...
When To Use
● Symptoms include null checks on properties
● Conditional logic to display an object
● Use of a placeholder
Demo
● Bespoke: lib/search/solr/empty_result_set.rb
● Cheetah:
lib/cheetah/messenger/null_messenger.rb
● Display_case: lib/disp...
Extra Reading
Blog post on Factory Girl NullFactory class:
http://robots.thoughtbot.com/design-patterns-in-
the-wild-null-...
Upcoming SlideShare
Loading in …5
×

0

Share

Download to read offline

Null object pattern

Download to read offline

Introduces design patterns and introduces the null object pattern, symptoms indicating it should be applied, a demonstration, and examples in popular Ruby gems

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all
  • Be the first to like this

Null object pattern

  1. 1. Null Object Pattern Simplicity in doing nothing
  2. 2. What is a Design Pattern? ● A reusable solution to a common problem ● Kent Beck and Ward Cunningham applied to computer science in 1987 ● Defined in Design Patterns: Elements of Reusable Object-Oriented Software by GoF
  3. 3. Null Object Pattern ● Categorized as behavioral pattern ● Similar to the strategy, or state pattern ● Polymorphism ● null interface that can be used by a collaborator
  4. 4. When To Use ● Symptoms include null checks on properties ● Conditional logic to display an object ● Use of a placeholder
  5. 5. Demo
  6. 6. ● Bespoke: lib/search/solr/empty_result_set.rb ● Cheetah: lib/cheetah/messenger/null_messenger.rb ● Display_case: lib/display_case/exhibit.rb (null decorator) ● Factory_girl: lib/factory_girl/null_factory.rb Examples in our Code
  7. 7. Extra Reading Blog post on Factory Girl NullFactory class: http://robots.thoughtbot.com/design-patterns-in- the-wild-null-object

Introduces design patterns and introduces the null object pattern, symptoms indicating it should be applied, a demonstration, and examples in popular Ruby gems

Views

Total views

1,854

On Slideshare

0

From embeds

0

Number of embeds

976

Actions

Downloads

6

Shares

0

Comments

0

Likes

0

×