Why is this convention for event handler suffixes using a "handler"? Why not attach them to the pen?

I have noticed that this is a common (at least in ECMAScript) suffix event handlers using the "handler": clickHandler, fooBarHandleretc. But I always thought that it makes sense to attach them to "handle ': handleClick, handleFooBaretc.

With prefix notation, methods are much easier to visually analyze (it’s very easy to distinguish between handlers and other things), find (or ignore) faster with the text of the editor text, and they adhere to the agreement that methods should be verbs ( handleClick- this is a verb, clickHandler- a noun).

So why the general notation of suffixes? Is there a hidden benefit that I have not noticed?

+3
source share
7 answers

The traditional flash naming convention uses "on" as a prefix, not a "handler" as a suffix. Some people prefer verb method names, some prefer noun names. The name onMouseClick is more like an adverb, mouseClickHandler is a noun that sounds like a class name, and handleMouseClick is a verb.

"", Adobe Flex, "on" ( ) . Flex Builder, Ctrl-O, , "on" .

+2

. , , .

+3

, , , .

, eventHandler.

+2

, , , " ". . , , , , , - , , .

+2

(ClickHandler) . , ( ClickHandler) , . Visual Studio 2010 .

+1

- , , - . .

+1

"" /, . - . C FILE *, x86.

, , . , .

+1

Source: https://habr.com/ru/post/1714898/


All Articles