Command Pattern in Go: Encapsulating Requests as Objects
Command Pattern turns requests into objects. Instead of directly calling a method, you create a command object that encapsulates all information about the action: what to do, with what parameters, on which object.
It’s like an order in a restaurant: the waiter doesn’t cook the food themselves, they write the order on paper and pass it to the kitchen. The paper is the command. It can be delayed, canceled, repeated, or passed to another cook.
Continue reading