Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command, CommandHandler and CommandInvoker

I recently saw a new pattern (new to me) in an open source ASP.NET MVC 3 project that hase many Command, CommandHandler, and CommandInvoker -with their interfaces- and I can't understand the pattern! Can you tell me what is this pattern's name and where can I learn about it? And what is its benefits please? Thanks in advance.

Update: I'm talking about this project:

An image gallery with RavenDB

like image 773
amiry jd Avatar asked Sep 13 '12 09:09

amiry jd


People also ask

What is a Commandhandler?

A Command Handler is essentially a way to separate your commands into different files, instead of having a bunch of if/else conditions inside your code (or a switch/case if you're being fancy). In this case, the code shows you how to separate each command into its own file.

What are commands in DDD?

A command is an object that is sent to the domain for a state change which is handled by a command handler. They should be named with a verb in an imperative mood plus the aggregate name which it operates on. Such request can be rejected due to the data the command holds being invalid/inconsistent.

What is command pattern in C#?

The Command pattern is a behavioral design pattern that we can use to turn a request into an object which contains all the information about the request. The Command design pattern is quite popular in C#, especially when we want to delay or queue a request's execution or when we want to keep track of our operations.


1 Answers

Take a look at this article: Meanwhile… on the command side of my architecture

It contains a thorough explanation about why you want to use commands and command handlers as part of your architecture. An architectural pattern such as CQRS is based on commands and events, but even without applying CQRS, the use of commands in your architecture is very valuable, as the article explains.

The RavenGallery project, however, is too small to really see the benefits of this command/handler model. This model starts to shine when a project gets bigger.

A more thorough discussion on this topic can be found in chapter 10 of my book.

like image 150
Steven Avatar answered Oct 18 '22 08:10

Steven