Hi Sreeraj,
you may not have noticed, but the second version of code, you provided, uses the decorator pattern as well
The original design makes a distinction between the basic beverage (the
coffee variations) and the add-ons (milk, whip and so on), whereas you combined all of them to extend a common base class.
Although your approach is valid as well, I yould prefer the original one, as it is clearer in terms of valid variations: with your approach you could shake a "Mocha with Decaf" - kind of odd, isn't it
Greetings,
Frank