What is the best way to write the code ?
(1) Like directly writing the code in the button_click()
event.
or
(2) Make the function of that code which I write in button_click()
event and write this function in one class and then that function I should call in the button_Click()
event.Like is it called three-tier approach
to write the code ?
Like in button_Click()
event I write the code to save the records in csv file from datatable
.So I should write that code in button_Click()
event or I should make one new function and one new class and write that code in that function which is the new class and calling that function in button_Click()
event.
This is only one example but I am talking about all the code written in my application that which is the appropriate and best way to write the code
and what are the benefits ? Note that I write the code in Winforms with c#.