I am making a calculator program and i was wondering...what would be better...storing all the operators code in a function or would putting all the operators code in the buttons themselves be the better way to go.?
thanks.
Printable View
I am making a calculator program and i was wondering...what would be better...storing all the operators code in a function or would putting all the operators code in the buttons themselves be the better way to go.?
thanks.
If you have the tendency to be able to reuse the codes with new arguments or parameter, then place your operation in a function.
However, if you are just using that piece of code only one time, then you can just stick it in your command buttons.
It is not recommended to write fuction under the control method itself.
For Calculator sample program, I think here Planet Source Code have a lot that you can use it as your reference. :)