I was explaining Decorator pattern to a colleague of mine and came up with a little coding exercise, code kata to practice.
Here is the task:
Get a class that always outputs “Hello world”. Surround that string with round brackets and then with square brackets, then with round brackets again. You should have 2 decorators. Each decorator can only add a single set of brackets. Output should be “([(Hello world)])”. Also it should be very easy to change order of brackets or add more brackets.
Here is my stub at it.