Functionality code in a bad practice event handler?

I read some coding standards in C # and it has the following:

"The event handler should not contain code to perform the required action. Rather, call another method from the event handler

I was wondering if there is a reason for this (performance or something else) or if this is just a style preference?

+4
source share
1 answer

An event handler is designed to connect a graphical interface to your business logic.

If you have a text box for entering the username and the Add button, clicking the Add button should just call _userRepository.AddUser(UsernameTextbox.Text) . You do not need business logic in event handlers.

+7
source

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


All Articles