C# code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pohihihi

    #1

    C# code

    I know this is in vs2005 but is there a way to

    1- Divide class or move some helper methods on to another file and still be able to use in main file.

    2- Is there a way I can move similer files under one folder under a project under a solution and still be able to use that code.

    I tried both in my ways but did not work. Just wondering if possible.

    Thanks,
    Po
  • Gabriel Magaña

    #2
    Re: C# code

    Got no time for a complete example, but look into "public partial class"
    declaration syntax...


    Comment

    • Pohihihi

      #3
      Re: C# code

      I sould have been clear, actually I was looking in to 2003.


      "Gabriel Magaña" <no-spam@no-spam.com> wrote in message
      news:%23ip7OwMD GHA.2436@TK2MSF TNGP15.phx.gbl. ..[color=blue]
      > Got no time for a complete example, but look into "public partial class"
      > declaration syntax...
      >[/color]


      Comment

      • Eric Renken

        #4
        Re: C# code

        The best way to do this in 2003 would be by creating "abstract" classes. You cant name the class the same as the derived class but I think this would give you the functionality you want.

        You can create folders in your 2003 projects and still access those classes. Classes created in these subfolders take on the namesspace of the subfolder appended to the project namespace.

        Example:

        MyProject
        ClassGroup1
        MyClass.cs

        In that structure the namespace of "MyClass" would be by default "MyProject.Clas sGroup1"

        Eric Renken

        "Pohihihi" <noemail@hotmai l.com> wrote in message news:%23GGzTYMD GHA.140@TK2MSFT NGP12.phx.gbl.. .
        I know this is in vs2005 but is there a way to

        1- Divide class or move some helper methods on to another file and still be able to use in main file.

        2- Is there a way I can move similer files under one folder under a project under a solution and still be able to use that code.

        I tried both in my ways but did not work. Just wondering if possible.

        Thanks,
        Po

        Comment

        • Pohihihi

          #5
          Re: C# code

          I do have classes abstract but I wanted to organize and make big files small to make it more managable. Folder thing will be help in that case. Thanks.

          "Eric Renken" <EricRRenken@ne wsgroup.nospam> wrote in message news:OUgM%23zND GHA.4000@TK2MSF TNGP10.phx.gbl. ..
          The best way to do this in 2003 would be by creating "abstract" classes. You cant name the class the same as the derived class but I think this would give you the functionality you want.

          You can create folders in your 2003 projects and still access those classes. Classes created in these subfolders take on the namesspace of the subfolder appended to the project namespace.

          Example:

          MyProject
          ClassGroup1
          MyClass.cs

          In that structure the namespace of "MyClass" would be by default "MyProject.Clas sGroup1"

          Eric Renken

          "Pohihihi" <noemail@hotmai l.com> wrote in message news:%23GGzTYMD GHA.140@TK2MSFT NGP12.phx.gbl.. .
          I know this is in vs2005 but is there a way to

          1- Divide class or move some helper methods on to another file and still be able to use in main file.

          2- Is there a way I can move similer files under one folder under a project under a solution and still be able to use that code.

          I tried both in my ways but did not work. Just wondering if possible.

          Thanks,
          Po

          Comment

          • kevin  cline

            #6
            Re: C# code

            As a matter of style, instead of splitting one class into multiple
            source files, it is generally better to split it into multiple classes
            first, then split out the helper classes into separate source files.
            Inside every large class is a number of smaller classes screaming to be
            let out.

            Comment

            • carion1

              #7
              Re: C# code

              I can see the frustration ahead. Walking into company abc and finding a crap ton of classes each spread across many files. I bet someone even comes up with some nifty naming convention for said files to easily (lol) keep track of what method is where (just say no). Not even solid gold meatballs could save that spaghetti. Please excuse me I just think this is a bad idea.

              --

              Derek Davis
              ddavis76@gmail. com
              "Pohihihi" <noemail@hotmai l.com> wrote in message news:%23GGzTYMD GHA.140@TK2MSFT NGP12.phx.gbl.. .
              I know this is in vs2005 but is there a way to

              1- Divide class or move some helper methods on to another file and still be able to use in main file.

              2- Is there a way I can move similer files under one folder under a project under a solution and still be able to use that code.

              I tried both in my ways but did not work. Just wondering if possible.

              Thanks,
              Po

              Comment

              • Pohihihi

                #8
                Re: C# code

                Surely the scenario you give does make it soung a bad idea. I am not looking for a big mess later. It is just a way to organize GUI forms. Bracking class might not be a good idea (but still it is supported in full swing in vs2005) but organizing similer controls or GUIs is. It is happening for many years now, it is just that I am trying to find if it is possible in vs IDE. As one of the replies on this thread suggested how folders will work and I guess that solves my problem.

                Thanks.
                "carion1" <ddavis76 _at_ gmail _dot_ com> wrote in message news:%23L2Cy9QD GHA.2988@TK2MSF TNGP10.phx.gbl. ..
                I can see the frustration ahead. Walking into company abc and finding a crap ton of classes each spread across many files. I bet someone even comes up with some nifty naming convention for said files to easily (lol) keep track of what method is where (just say no). Not even solid gold meatballs could save that spaghetti. Please excuse me I just think this is a bad idea.

                --

                Derek Davis
                ddavis76@gmail. com
                "Pohihihi" <noemail@hotmai l.com> wrote in message news:%23GGzTYMD GHA.140@TK2MSFT NGP12.phx.gbl.. .
                I know this is in vs2005 but is there a way to

                1- Divide class or move some helper methods on to another file and still be able to use in main file.

                2- Is there a way I can move similer files under one folder under a project under a solution and still be able to use that code.

                I tried both in my ways but did not work. Just wondering if possible.

                Thanks,
                Po

                Comment

                • Greg

                  #9
                  RE: C# code

                  Whenever a tool (especially a modern tool such as C# .NET) does not easily
                  lend itself to a certain way of doing things then:

                  maybe not ask: "How can I do it this way?"

                  but rather ask: "Maybe this is not the best way to do it?"

                  The purpose of classes is for logical object organization. If you have a
                  reason why you want other class elements in another file then maybe:

                  a.) you need another class.

                  or b.) use #region to separate/hide the various logical groups of items
                  within the class.

                  --
                  Greg McPherran
                  This domain is for sale! Fast and easy shopping. Trusted and secure since 2005.



                  "Pohihihi" wrote:
                  [color=blue]
                  > I know this is in vs2005 but is there a way to
                  >
                  > 1- Divide class or move some helper methods on to another file and still be able to use in main file.
                  >
                  > 2- Is there a way I can move similer files under one folder under a project under a solution and still be able to use that code.
                  >
                  > I tried both in my ways but did not work. Just wondering if possible.
                  >
                  > Thanks,
                  > Po[/color]

                  Comment

                  • Jon Skeet [C# MVP]

                    #10
                    RE: C# code

                    Greg <gm@mcpherran.c om> wrote:[color=blue]
                    > Whenever a tool (especially a modern tool such as C# .NET) does not easily
                    > lend itself to a certain way of doing things then:
                    >
                    > maybe not ask: "How can I do it this way?"
                    >
                    > but rather ask: "Maybe this is not the best way to do it?"[/color]

                    That's an excellent, excellent point. It's one which is particularly
                    worth bearing in mind when transitioning from one language or platform
                    to another - not just when porting code, but when approaching a problem
                    which you might have tackled in one way in another language, but which
                    seems a pain in the new one.

                    Hear hear, basically :)

                    --
                    Jon Skeet - <skeet@pobox.co m>
                    http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
                    If replying to the group, please do not mail me too

                    Comment

                    • carion1

                      #11
                      Re: C# code

                      Well said.

                      --

                      Derek Davis
                      ddavis76@gmail. com

                      "Greg" <gm@mcpherran.c om> wrote in message
                      news:88241DFC-4A35-4B94-AC87-86BCCC963A77@mi crosoft.com...[color=blue]
                      > Whenever a tool (especially a modern tool such as C# .NET) does not easily
                      > lend itself to a certain way of doing things then:
                      >
                      > maybe not ask: "How can I do it this way?"
                      >
                      > but rather ask: "Maybe this is not the best way to do it?"
                      >
                      > The purpose of classes is for logical object organization. If you have a
                      > reason why you want other class elements in another file then maybe:
                      >
                      > a.) you need another class.
                      >
                      > or b.) use #region to separate/hide the various logical groups of items
                      > within the class.
                      >
                      > --
                      > Greg McPherran
                      > www.McPherran.com
                      >
                      >
                      > "Pohihihi" wrote:
                      >[color=green]
                      >> I know this is in vs2005 but is there a way to
                      >>
                      >> 1- Divide class or move some helper methods on to another file and still
                      >> be able to use in main file.
                      >>
                      >> 2- Is there a way I can move similer files under one folder under a
                      >> project under a solution and still be able to use that code.
                      >>
                      >> I tried both in my ways but did not work. Just wondering if possible.
                      >>
                      >> Thanks,
                      >> Po[/color][/color]


                      Comment

                      • carion1

                        #12
                        Re: C# code

                        If you really think about it, proper class design will render exactly what you want in a slightly different fashion. In terms of organization you might think about an N-Tier design even if all the pieces will reside on the client machine.

                        --

                        Derek Davis
                        ddavis76@gmail. com
                        "Pohihihi" <noemail@hotmai l.com> wrote in message news:erxKSfUDGH A.1544@TK2MSFTN GP10.phx.gbl...
                        Surely the scenario you give does make it soung a bad idea. I am not looking for a big mess later. It is just a way to organize GUI forms. Bracking class might not be a good idea (but still it is supported in full swing in vs2005) but organizing similer controls or GUIs is. It is happening for many years now, it is just that I am trying to find if it is possible in vs IDE. As one of the replies on this thread suggested how folders will work and I guess that solves my problem.

                        Thanks.
                        "carion1" <ddavis76 _at_ gmail _dot_ com> wrote in message news:%23L2Cy9QD GHA.2988@TK2MSF TNGP10.phx.gbl. ..
                        I can see the frustration ahead. Walking into company abc and finding a crap ton of classes each spread across many files. I bet someone even comes up with some nifty naming convention for said files to easily (lol) keep track of what method is where (just say no). Not even solid gold meatballs could save that spaghetti. Please excuse me I just think this is a bad idea.

                        --

                        Derek Davis
                        ddavis76@gmail. com
                        "Pohihihi" <noemail@hotmai l.com> wrote in message news:%23GGzTYMD GHA.140@TK2MSFT NGP12.phx.gbl.. .
                        I know this is in vs2005 but is there a way to

                        1- Divide class or move some helper methods on to another file and still be able to use in main file.

                        2- Is there a way I can move similer files under one folder under a project under a solution and still be able to use that code.

                        I tried both in my ways but did not work. Just wondering if possible.

                        Thanks,
                        Po

                        Comment

                        • carion1

                          #13
                          Re: C# code

                          When I said N-Tier design I should have been a little more clear. I mean break things up into diff projects (business layer, data layer).

                          --

                          Derek Davis
                          ddavis76@gmail. com
                          "carion1" <ddavis76 _at_ gmail _dot_ com> wrote in message news:esDKF2XDGH A.336@TK2MSFTNG P14.phx.gbl...
                          If you really think about it, proper class design will render exactly what you want in a slightly different fashion. In terms of organization you might think about an N-Tier design even if all the pieces will reside on the client machine.

                          --

                          Derek Davis
                          ddavis76@gmail. com
                          "Pohihihi" <noemail@hotmai l.com> wrote in message news:erxKSfUDGH A.1544@TK2MSFTN GP10.phx.gbl...
                          Surely the scenario you give does make it soung a bad idea. I am not looking for a big mess later. It is just a way to organize GUI forms. Bracking class might not be a good idea (but still it is supported in full swing in vs2005) but organizing similer controls or GUIs is. It is happening for many years now, it is just that I am trying to find if it is possible in vs IDE. As one of the replies on this thread suggested how folders will work and I guess that solves my problem.

                          Thanks.
                          "carion1" <ddavis76 _at_ gmail _dot_ com> wrote in message news:%23L2Cy9QD GHA.2988@TK2MSF TNGP10.phx.gbl. ..
                          I can see the frustration ahead. Walking into company abc and finding a crap ton of classes each spread across many files. I bet someone even comes up with some nifty naming convention for said files to easily (lol) keep track of what method is where (just say no). Not even solid gold meatballs could save that spaghetti. Please excuse me I just think this is a bad idea.

                          --

                          Derek Davis
                          ddavis76@gmail. com
                          "Pohihihi" <noemail@hotmai l.com> wrote in message news:%23GGzTYMD GHA.140@TK2MSFT NGP12.phx.gbl.. .
                          I know this is in vs2005 but is there a way to

                          1- Divide class or move some helper methods on to another file and still be able to use in main file.

                          2- Is there a way I can move similer files under one folder under a project under a solution and still be able to use that code.

                          I tried both in my ways but did not work. Just wondering if possible.

                          Thanks,
                          Po

                          Comment

                          • Greg

                            #14
                            Re: C# code

                            The partial classes in C# 2005 seem to be exactly what you you are looking
                            for. Therefore it seems to confirm that there is no designated way to do this
                            C# 2003.
                            So, you basically have your answer.
                            --
                            Greg McPherran
                            This domain is for sale! Fast and easy shopping. Trusted and secure since 2005.



                            "Pohihihi" wrote:
                            [color=blue]
                            > I sould have been clear, actually I was looking in to 2003.
                            >
                            >
                            > "Gabriel Magaña" <no-spam@no-spam.com> wrote in message
                            > news:%23ip7OwMD GHA.2436@TK2MSF TNGP15.phx.gbl. ..[color=green]
                            > > Got no time for a complete example, but look into "public partial class"
                            > > declaration syntax...
                            > >[/color]
                            >
                            >
                            >[/color]

                            Comment

                            Working...