I recently learned interpreter pattern. I found some similarities betweeen decorator and interpreter. They have similar structure.
I look in this case: one nonTerminal behaviour and one terminal behaviour in interpreter. It seems very similar to decorator. There can be nonTerminal behaviour calling same nonTerminal beahviour and then calling terminal behaviour. This seems very similar to apply decorator over same decorator over objet.
Is decorator a specail case of interpreter?
Decorator pattern is primarily to decorate an existing object and adding additional capabilities to the decorated object, example BufferedReader and FilerReader: where FileReader reads data character by character and BufferedReader reads data line by line
The interpreter pattern is used to interpret a language or an expression.
Both are completely different since the interpreter is interpreting an expression and decorator is enhancing an existing object, its not interpreting an expression....its usually after the interpretion the decoration can happen....