Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Naming Convention for Commands & Events

I'm just getting into event-driven architectures and would like to know what the convention is for naming commands and events. I know this much: Commands should be in the form DoSomething while events should be in the form SomethingHappened. What I need to clarify is if I need to append the word 'Command' to my commands and 'Event' to my events e.g. DoSomethingCommand as opposed to just DoSomething and SomethingHappenedEvent as opposed to just SomethingHappened. I would also like to know what the rationale is behind the community-preferred convention. Thanks!

like image 542
Tolu Avatar asked Sep 20 '12 10:09

Tolu


People also ask

What is naming convention and example?

A naming convention can include capitalizing an entire word to denote a constant or static variable (which is commonly done in Flash programming), or it could be a simple character limit in a coding language (such as SQL).

What naming convention does Magento 2 require?

That said, the convention among the more engineering focused Magento developers is to use a lowercased version of the full module name for third party modules ( namespace_helloworld. xml ).

Why are naming conventions used?

Why use naming conventions? Naming records consistently, logically and in a predictable way will distinguish similar records from one another at a glance, and by doing so will facilitate the storage and retrieval of records, which will enable users to browse file names more effectively and efficiently.


1 Answers

The Command and Event suffixes are optional and are a matter of preference. I prefer to omit them and try to make the intent evident from the name alone. The most important aspect of naming commands and events is making sure they reflect the business domain more so than the technical domain. A lot of times terms like Create, Update, Add, Change are far too technical and have less meaning in the business domain. For example, instead of saying UpdateCustomerAddress you can say RelocateCustomer which could have a larger business context to it.

like image 91
eulerfx Avatar answered Oct 18 '22 22:10

eulerfx