Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 5 down vote accepted

Other naming options may include:

Format 1: On[Objectname][DetailedEventName]

Example:

OnMouseClick

OnMouseRightButtonClick

Format 2: On[DetaieldConditionName]

Examples:

OnRecordNotFound

OnCustomerRowNotFound

Other posts related to this: StackOverFlow-EventNames

share|improve this answer
    
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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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