CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2012
    Posts
    36

    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

  2. #2
    Join Date
    Mar 2014
    Posts
    1

    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.

  3. #3
    Join Date
    May 2012
    Posts
    36

    Re: Code structure question

    Thanks, Nikola.Lukovic,

    I like the regions Idea, this may help. I also agree with good comments.

    Take Care,

    -Mike


    Quote Originally Posted by Nikola.Lukovic View Post
    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
  •  





Click Here to Expand Forum to Full Width

Featured