Clean code recommends to name methods to be a verb, and classes to be a noun.

I am developing an c++ application using boost::signal as some kind of event framework, and have defined various events, but naming them to make the code cleaner seems to be problematic.

So, how to name event types?


Other naming options may include:

Format 1: On[Objectname][DetailedEventName]




Format 2: On[DetaieldConditionName]




Other posts related to this: StackOverFlow-EventNames

  • Hehe defnitly the better way :-) – Smokefoot Feb 27 '12 at 11:53

Robert C. Martin mentioned that your names have to be meanful and searchable. It should be a verb or a verb phrase. So from my point of view I would allways clarify that this method is a event by building a verb phrase.

Some examples could be: - SaveEvent() - RenderEvent() - CloseEvent()

Whit this format I am allways able to find the Event-Method. I know exactly that this method is a event and I dont need to seach for some points that let me know that this method is a event.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.