© Dmitri Nesteruk 2019
Dmitri NesterukDesign Patterns in .NEThttps://doi.org/10.1007/978-1-4842-4366-4_15

15. Command

Dmitri Nesteruk1 
(1)
St. Petersburg, c.St-Peterburg, Russia
 

Think about a trivial variable assignment, such as meaningOfLife = 42. The variable got assigned, but there’s no record anywhere that the assignment took place. Nobody can give us the previous value. We cannot take the fact of assignment and serialize it somewhere. This is problematic, because without a record of the change, we are unable to roll back to previous values, perform audits, or do history-based debugging.1

The Command design pattern proposes that, instead of working with objects directly by manipulating them through their APIs, we send them commands, or instructions ...

Get Design Patterns in .NET: Reusable Approaches in C# and F# for Object-Oriented Software Design now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.