I am trying to learn the decorator design pattern.
The scenario i have though for a good use and to learn coding it is as follows:
A command line output program. The decorators will wrap an outputText class and add additional ability to the output such as text colour, bold text, blinking text etc.
Would this be considered a good use of this pattern or am i missing the point of it?
I think your idea is sound. It’s very similar to the text editor sample given in the GoF book.
In that book they use the example of a text editor, with classes for drawing windows, bolding text, etc. They use examples for the decorator pattern in one chapter which mimic what you describe, so I’d say you’re on the right track.
so taking it further, you would have a decorator class for italic text, another for bolding text, etc. OK, one could argue that you could have a class to do this for you e.g.
TextFormatter, but you just need to use what is right for your situation.