Difference between functions

Difference between functions

Hello everyone,

I would like to know what is the difference between using direct code in the forms, either in a field change or when loading the form, and using a function, since thinking a little, at the moment of performing the function, I will have to call it with some condition that it could be the change of a field or something like that, I don't know if he explained it to me.

Thanks in advance