Splitting a class

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

    Splitting a class

    Hi,

    Using C#, .NET 1.1

    I have a class that has many methods. It is my datalayer. Some methods are
    related to each other and I want to make my code more manageable by
    seperating the related methods.

    Is there any way I can put my related methods into seperate files while
    still maintaining those methods as part of the class?

    I have seen that .NET 2 has partial classes (not yet sure what they do) but
    is there anything I can do for .net 1.1?

    Thanks.

    Best regards,
    Dave Colliver.
    最新免费影视资源站,每日更新高清电影电视剧在线观看,提供最新热门电影、电视剧、动漫、综艺等影视资源,高清流畅播放,完全免费观看。

    ~~
    http://www.FOCUSPortals.com - Local franchises available


  • Jon Skeet [C# MVP]

    #2
    Re: Splitting a class

    David <david.colliver .NEWS@revilloc. REMOVETHIS.comw rote:
    Using C#, .NET 1.1
    >
    I have a class that has many methods. It is my datalayer. Some methods are
    related to each other and I want to make my code more manageable by
    seperating the related methods.
    >
    Is there any way I can put my related methods into seperate files while
    still maintaining those methods as part of the class?
    >
    I have seen that .NET 2 has partial classes (not yet sure what they do) but
    is there anything I can do for .net 1.1?
    There's nothing equivalent to partial classes in 1.1, but if your class
    is particularly large (and particularly if it breaks up into "chunks"
    of methods neatly) you should quite possibly consider breaking the
    class itself (rather than just the source code) into several classes.
    Think about whether you could compose a "top level" class from multiple
    classes which neatly encapsulate part of the behaviour/state without
    needing to relate to the rest of the existing class.

    --
    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

    • David

      #3
      Re: Splitting a class

      Thanks. I thought maybe not.

      I will try and split the class up.

      Best regards,
      Dave Colliver.

      ~~
      http://www.FOCUSPortals.com - Local franchises available


      "Jon Skeet [C# MVP]" <skeet@pobox.co mwrote in message
      news:MPG.201ca2 1b3b3f0b0c98d7d c@msnews.micros oft.com...
      David <david.colliver .NEWS@revilloc. REMOVETHIS.comw rote:
      >Using C#, .NET 1.1
      >>
      >I have a class that has many methods. It is my datalayer. Some methods
      >are
      >related to each other and I want to make my code more manageable by
      >seperating the related methods.
      >>
      >Is there any way I can put my related methods into seperate files while
      >still maintaining those methods as part of the class?
      >>
      >I have seen that .NET 2 has partial classes (not yet sure what they do)
      >but
      >is there anything I can do for .net 1.1?
      >
      There's nothing equivalent to partial classes in 1.1, but if your class
      is particularly large (and particularly if it breaks up into "chunks"
      of methods neatly) you should quite possibly consider breaking the
      class itself (rather than just the source code) into several classes.
      Think about whether you could compose a "top level" class from multiple
      classes which neatly encapsulate part of the behaviour/state without
      needing to relate to the rest of the existing class.
      >
      --
      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

      Working...