>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().The second case is right. Buttons should send messages to the objects (methods) that know what to do with the information.
If btnAccept knows too much about what Accept means, then it is not reusable. You cannot drop it into a new form as its code would not fit the situation. OTOH the container (in this case most likely a form), should know what Accept() means in that particular, (concrete) instance, and can act accordingly.
See:
http://fox.wikis.com/wc.dll?Wiki~EventsShouldAlwaysCallMethodshttp://fox.wikis.com/wc.dll?Wiki~ClassAndObjectHeuristics