It's not a secret anymore!*
The moose likes OO, Patterns, UML and Refactoring and the fly likes Decorator Pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Decorator Pattern" Watch "Decorator Pattern" New topic
Author

Decorator Pattern

Maan Suraj
Ranch Hand

Joined: Dec 20, 2007
Posts: 299
I was going through decorator pattern from Head First. On one of the pages,it says that

" When i inherit behaviour by subclassing,that behaviour is set statically at compile time"


I am not getting what does "statically at compile time means in this context".




Man Suraj
Someone says "Impossible is nothing". The man next him says "Let me see you licking your elbow tip!"
ramesh maredu
Ranch Hand

Joined: Mar 15, 2008
Posts: 210

I read it long back,if I am correct, the book is comparing between inheritance and composition.

When you extend a class and make a subclass then you get the behavior of super class and the behavior is static (you can not change the behavior at runtime). But if you compose then the behavior you get with composed reference could be dynamic.








SCJP 1.5 94%.
The greatest glory in living lies not in never falling, but in rising every time we fall.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Decorator Pattern