-
March 21st, 2014, 09:24 AM
#1
Code structure question
Hello,
I'm trying to learn how to properly organize code. But I was wondering to start if it is possible to have any code that is in a button or form load event, to be called to another .cs file.
This way I can organize my code better and have each button event run its code from a .cs file and not the main form.cs file.
Might sound strange, but I'm just learning and do not really understand OOP yet. So this will at least help me get my code into buckets.
Thanks and any information will be great.
Take Care,
-Mike
-
March 22nd, 2014, 02:51 AM
#2
Re: Code structure question
With larger and larger projects your method of code organizing would really fast create a really big problem of too much files. You would lose count on them. What you can do is to use:
comments - to explain what is happening in the code
regions - to colapse big chunks of code, and
partial classes - if your class is going to be big, with alot of methods, properties, etc... you can divide one class in multiple files.
In my personal experience, this practice was more than enough for good code readability.
-
March 22nd, 2014, 02:20 PM
#3
Re: Code structure question
Thanks, Nikola.Lukovic,
I like the regions Idea, this may help. I also agree with good comments.
Take Care,
-Mike
Originally Posted by Nikola.Lukovic
With larger and larger projects your method of code organizing would really fast create a really big problem of too much files. You would lose count on them. What you can do is to use:
comments - to explain what is happening in the code
regions - to colapse big chunks of code, and
partial classes - if your class is going to be big, with alot of methods, properties, etc... you can divide one class in multiple files.
In my personal experience, this practice was more than enough for good code readability.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|