Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should an event object be named as a past tense verb or a noun?

I have been reading several event sourcing articles and examples. I have seem some as verbs, and others name as nouns with both of which might have event tacked on the end. Which is more correct? One example would be. OrderShippedEvent ( or sometimes just OrderShipped) vs ShipOrderEvent. The tense of the methods that operate on these types of objects have not helped much either. Here are some examples I've found.

process(OrderShippedEvent);

or

apply(ShipOrderEvent);

in other cases there will be handlers like

HandleOrderShipped(OrderShippedEvent)

or

HandleShipOrder(ShipOrderEvent)

I assume there should be a standard way to name and handle any type of events in any context, although I'm most interested in an Event Sourcing scenario.

like image 236
awright18 Avatar asked Jun 26 '11 01:06

awright18


1 Answers

Well, they mean different things:

  • ShipOrderEvent means that a an order is about to be shipped, but we have no certainty as whether it has or hasn't been shipped yet.
  • OrderShippedEvent means that the order has been shipped, for sure.

They are smilar to the FormClosing/FormClosed events of the System.Windows.Forms.Form class in .NET. So, rather than suggesting what name to use, I'd rather suggest that you think what you want to represent by your event, and name it accordingly.

like image 92
CesarGon Avatar answered Oct 06 '22 00:10

CesarGon