Hi guys. I am struggling to understand when do I put code in the form class and when do I create a seperate class to insert the code into there. An example would be. I created a program that stores meta data for movies in a xml file using xml serialization. I never created any classes and inserted all the code into the forms class. My question is should I have created the xml serialization into a different class and just called that up from a button click event. My main question is when do I use a seperate class and when do I write the code into my forms class.
Would if of been better if I created a property for the movie so in abuttons event when I save the xml I could just say
movie.year = txtyear.text
Movie.genre = "Comedy"
Thank you
form or seperate class code
- rustypup
- Registered User
- Posts: 8872
- Joined: 13 Dec 2004, 02:00
- Location: nullus pixius demonica
- Contact:
Re: form or seperate class code
Most people would sooner die than think; in fact, they do so - Bertrand Russel
Re: form or seperate class code
Am I correct in guessing WinForms in VB.NET or C# geraldhum?
Important Thread:
- Hey everybody, I have returned (2013) and I am not Dead.
- Explaining RAM - SDRAM, DDRx and GDDR
Re: form or seperate class code
Hi Guys, I'm sorry I thought I put my coding language but I am using Winforms and c#
- rustypup
- Registered User
- Posts: 8872
- Joined: 13 Dec 2004, 02:00
- Location: nullus pixius demonica
- Contact:
Re: form or seperate class code
if you're creating something to be used once-off or for a very brief instance, then fine... leave the functional code there.
but it's definitely considered poor, unmaintainable, practice for anything else... you don't want the event stack validating and shunting data, you want it as light and responsive as possible.
so, to answer the question, separate class....
read through the MVC link...
but it's definitely considered poor, unmaintainable, practice for anything else... you don't want the event stack validating and shunting data, you want it as light and responsive as possible.
so, to answer the question, separate class....
read through the MVC link...
Most people would sooner die than think; in fact, they do so - Bertrand Russel