Skilled Coder
Jan 6, 2024

--

Thanks Vasudev

This design choice is akin to real-world situations where different teams might handle the implementation of the ScientificCalculator class.

In everyday terms, having the Command interface as part of the ScientificCalculator class is like having a smart remote control. Each button on the remote represents a different operation (like add, subtract, or sin). This way, it's easy to switch between actions, and if you want to add a new button (operation), you don't need to mess with the inner workings of the remote. It keeps things organized, just like how different teams might handle specific features of a gadget in real life.

So using Command allows for flexible operations like undo/redo and easy switching between strategies. If you only need direct strategy management, using OperationStrategy directly might be simpler. It depends on specific needs and design goals.

--

--

Skilled Coder
Skilled Coder

Written by Skilled Coder

Sharing content and inspiration on programming. Coding Newsletter : https://skilledcoder.substack.com

Responses (1)