Michael Farouk

Decorator Pattern is a structural pattern that allows for the dynamic wrapping of objects in order to modify their existing responsibilities and behaviors and leads to the Open Close Principle (Closed for Modification, Open for Extension) One of the most important software principles of the development process that developers have to consider in change, the Decorator pattern helps us to design code avoiding modification, while still extending that code if needed.


We want to add behavior or state to individual objects at run-time. Inheritance is not feasible because it is static and applies to an entire class at the compile time.


Description: D:\TIEC Android Program\Books\decorator-design-pattern-example-uml-class-diagram.png

We solved this using the decorator pattern by designing a new decorator class that wraps the original class. This wrapping could be achieved by the following sequence of steps:

  1. Create Subclass from the original "Component" class called "Decorator" Class.
  2. In this subclass - "Decorator" Class - add a Component pointer as a field.
  3. Pass a Component to the Decorator constructor to initialize the Component field pointer.
  4. In the Decorator Class, redirect all "Component" methods to the "Component" field pointer.
  5. In the ConcreteDecorator Class, override any Component method(s) whose behavior needs to be modified.


Finally, when we want to add some functionality to individual object or change the state of particular object at run time it is not possible; however, we can provide the specific behavior to all the objects of that class at design time by the help of inheritance or using subclass, but Decorator pattern makes it possible to provide individual object of same class a specific behavior or state at run time. This doesn’t affect other object of same Class.

Reference : http://en.wikipedia.org/wiki/Decorator_pattern


1-There are no limits. There are plateaus, but you must not stay there, you must go beyond them.

2-There is no such thing as maturity. There is instead an ever-evolving process of maturing.

3-Faith makes it possible to achieve that which man's mind can conceive and believe.

4-Don't get set into one form, adapt it and build your own, and let it grow, be like water. Empty your mind, be formless, shapeless — like water. Now you put water in a cup, it becomes the cup; You put water into a bottle it becomes the bottle; You put it in a teapot it becomes the teapot. Now water can flow or it can crash.

5-Always be yourself, express yourself, have faith in yourself, do not go out and look for a successful personality and duplicate it.

6-If you love life, don't waste time, for time is what life is made up of.

7-Mistakes are always forgivable, if one has the courage to admit them.

8-A wise man can learn more from a foolish question than a fool can learn from a wise answer.

9-I fear not the man who has practiced 10,000 kicks once, but I fear the man who has practiced one kick 10,000 times.


Continuing with our list of punctuation marks and their uses, here are the rest of the most important and most used marks:

  • The Full Stop/Period (.):

Usage: As the name signifies, it indicates the end of a sentence (I like English.), or with abbreviations (Co. == Company), or initials (Amgad Y. Kaldas).

Format: Space is added after the full stop, but not before. The full stop is followed by upper case word.

  • The Quotation Marks ("  ", '  '):

Usage: Around artistic names (Books, movies, Albums, etc…), for dialogues ("Good morning, Frank," said Hal.), for unusual usage of words and irony (Crystals somehow "know" which shape to grow into.) and (He shared his "wisdom" with me.), and for distinction ("Cheese" is derived from a word in Old English.).

Format: Spaces are added outside the quotation marks (before the opening and after the closing marks), but not inside (xx "xxx" yyy).

  • Ellipsis Mark (…):

Usage: in place of cut off text that won't affect the meaning of the sentence (The film focused on three English learners...studying at university.), or to implicate that there's more to say while chatting, or instead of listing so many items that are already understandable from the first few examples- and so forth or etc.,  or to indicate a pause in a dialogue.

Format: depends on your style, can have space before and after, between, or no spaces around. When at the end of a sentence, a fourth one is usually added as a full stop.

  • Hyphen (-):

Usage: to join words and to separate syllables of a single word (book-case, or a blue-eyed boy), with prefixes (self-motivated, non-English), or in justified text for wrapping a long word at the end of the line.

Format: no spaces on either side of the hyphen.

  • Dash (–, —):

Usage: as a colon to introduce a list, to denote a break in a sentence or to set off parenthetical statements (A flock of sparrows—some of them juveniles—alighted and sang.), or to indicate spans/ranges (pp. 38-55, for ages 3–5), or o show a pause or break in meaning in the middle of a sentence (My brothers—Richard and John—are visiting Hanoi.).

Format: for the "n dash", the smaller one, you can add space on either side, for the "m dash", usually no space are added.