• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

decorator design pattern

 
cherry hal
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Anybody can tell me about decorator designpattern
 
Punit Jain
Ranch Hand
Posts: 1012
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To extend or modify the behaviour of ‘an instance’ at runtime decorator design pattern is used.
Inheritance is used to extend the abilities of ‘a class’.
Unlike inheritance, you can choose any single object of a class and modify its behaviour leaving the other instances unmodified.
i mean if you use inheritance and extend super class to sub class, then say, you created 100 objects of that class, your class functionality will be in all the 100 objects.
but you want that functionality in 2 or 3 objects that time you can decorate that object run time, that is where decorator pattern is used.
 
Winston Gutkowski
Bartender
Pie
Posts: 10091
56
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cherry hal wrote:Anybody can tell me about decorator designpattern

It'd be too much to put here, but this might help.

Otherwise: Do you have a specific question about the pattern? Or something particular that you don't understand?

Winston
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic