How to call event handler of the changes before and after?

So there is a change event abstract data structures.
There are two handlers:
1. Called before the change. Complements and validates it (can prevent this change).
2. Called after the change. Leads the world in consistent with this change in status.

So, you have to come up with names.
It is important to do it now, because then in the code there are thousands of implementations of these handlers.

At the moment there are three pairs of candidates:
1. beforeChange and afterChange.
2. preChange and postChange.
3. validate and trigger.

While leaning toward the latter. Here are some pros and cons I see:
1.
+ Simple and clear
In as parameters both processors will be transferred to the state before the change and after, ie before and after, there will be confusion:
function beforeChange(before, after) {}
function afterChange(before, after) {}

- Names are not verbs.
2.
+ Almost as simple and clear.
- Names are not verbs.
3.
+ validate - verb.
+ Most often it will validate validation.
+ trigger a very accurate name.
in the validate is not only validation, its meaning is somewhat broader (I described above).
- trigger not a verb.
- some not so obvious titles like.

What do you say? Maybe there are some established names on this?
June 10th 19 at 16:59
2 answers
June 10th 19 at 17:01
that is, one handler you have handles the component itself and the second treats the other components, and "before" and "after" then do not make any sense, because the logic of these handlers belong to different objects

where the second logical processor to hang on to the component which must be synchronized with the first and hang on to it event listener changes the first component

your option is called micro-management, as if your head every time you said how you should do your job
that is, one handler you have handles the component itself and the second treats the other components, and "before" and "after" then do not make any sense, because the logic of these handlers belong to different objects

No, the handler "to" can check something in the external world (e.g., objects from our data structures).
Obrabotki differ from each other only in two things:
1. One is called before applying the changes to the data structure, and the other after.
2. The first can prevent the change and the other doesn't. - baron_Quigl commented on June 10th 19 at 17:04
any handler can check the value and condition of other elements and make the message about syncing an event at which he should work, just as you can know the location of your friends in FB or Twitter and decide to go to meet them, even if they are obviously not invited

there are no handlers to events, there are handlers that run on event - load, click, change, etc.

if you think that you have a handler "before the event", you simply ignore the actual event that this handler is run

you can't light a lamp before it hit the light switch, so there must be an event trigger, even if you don't want to see.

again, the handler of the ban on the change of the structure must belong to the object structure, and listen to your first event object, the value of which determines the possibility of changes in the structure: roughly speaking, the flag - if 1, then the light can be switched on and 0 to off

you do not have a clear and integral structure of the application you're working on, so you have to resolve the chaos of the supposedly different handlers, when in fact all engines are the same - Pedro65 commented on June 10th 19 at 17:07
June 10th 19 at 17:03
1) before and after are used in databases
2) In the States (programmable logic controllers) procedures are called enter (entry) and exit
That's interesting information.
I wonder what percentage of programmers expect to see it enter/exit. - baron_Quigl commented on June 10th 19 at 17:06

Find more questions by tags Source codeProgramming