Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Updated: design-patterns/decorator.html #18

Closed
wants to merge 1 commit into from

3 participants

@najamkhn

Shouldn't be using the same name as class for object instances.

@najamkhn najamkhn Updated: design-patterns/decorator.html
Shouldn't be using the same name as class for object instances.
e47a018
@maksimr

I do not agree with you. Why you say about 'Class'? Decorator allows you to add additional functionality to an object dynamically (In this example, the 'tree' is an object to which to add additional functionality.), this pattern was shown.

This pattern is described in detail in the book Stoyan Stefanov 'JavaScript Patterns'.

Thanks.

@shichuan
Owner

@najamkhn thanks for the request, but as @maksimr mentioned, the example is made to show adding functionality to an object. So it will be left as it is.

@shichuan shichuan closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 16, 2012
  1. @najamkhn

    Updated: design-patterns/decorator.html

    najamkhn authored
    Shouldn't be using the same name as class for object instances.
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 3 deletions.
  1. +3 −3 design-patterns/decorator.html
View
6 design-patterns/decorator.html
@@ -37,9 +37,9 @@
}
};
- tree = tree.getDecorator('BlueBalls');
- tree = tree.getDecorator('Angel');
- tree = tree.getDecorator('RedBalls');
+ var tree1 = tree.getDecorator('BlueBalls');
+ var tree2 = tree.getDecorator('Angel');
+ var tree3 = tree.getDecorator('RedBalls');
tree.decorate();
Something went wrong with that request. Please try again.