There are several problems with putting the entire save code (for example) into the Button.click().
One is, that you may need to save from different places. For instance, when you click the "next" button, you will want to save first. (This may requires additional considerations: clicking on "save" should save immediately; clicking on "next" will first check if there are changes, then ask for confirmation.)
Now, what happens if you change the button containership? For instance, move all buttons into a container, or out of it. You will have to change lots of code.
You may also want to save the current record from
outside of the form, for instance, from a ToolBar, or from a menu item. Again, the containership issue arrises. If you call a method _vfp.ActiveForm.OnSave() in a menu item, you don't need to change this. If you call _vfp.ActiveForm.CmdSave.Click(), and you later decide to put the buttons into a container ... again, you have to change lots of code.
You may even decide to eventually get rid of the button on the form alltogether! A ToolBar that applies to all forms uses less space than repeating buttons on every form. For instance, in older versions of Word, or Excel (the ones that use a main window, and child windows), the "Save" button is
not repeated in every individual window.
Now, perhaps you don't want to do this today. But what would happen if tomorrow, your boss says: "I don't want buttons on every individual form - use only a main toolbar"?
>I have the following doubt: which is the right place for the code?
>For example, if I have a form with three Command Buttons on it:
>btnAccept, btnCancel and btnDo, must the Click() event of each button have the code, or each one must do calls to forms methods, i.e.: ThisForm.Accept(), or ThisForm.Cancel(), etc.?
>I think the later is the right one, considering that the buttons are the User tier, and the form is the Business one, and everyone who wants to call those methods (a toolbar, for example), calls oRefToMyform.Do().
>But a teammate of mine says that all the code must reside in the class that do the job, and for him the button is who really does it, and a client who wants to use the services of this class, must call oRefToMyform.btnDo.Click().
>
>Sorry if it was too long, I will appreciate any suggestion
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)