Does it matter if one of my classes is very big?

Discussion in 'ASP .Net' started by Steve, Nov 15, 2006.

  1. Steve

    Steve Guest

    Hi I am working on a web application which will be accessed by
    thousands of visitors per day, so speed and performance is crucial to
    the application.

    One of the business logic classes in my project is now rather big (350
    lines) and expected to keep growing further and further...

    It is used in nearly all the webforms.

    Does its size affect peformance in anyway?

    Should I be creating more but smaller classes rather than putting most
    of my methods into one class?

    Very interested in what people have to say on this.

    Kind regards,

    Steve.
    Steve, Nov 15, 2006
    #1
    1. Advertising

  2. From performance perspective it is fine. Breaking a big class into smaller
    ones may be beneficial from the design and maintainability perspective.

    --
    Eliyahu Goldin,
    Software Developer & Consultant
    Microsoft MVP [ASP.NET]


    "Steve" <> wrote in message
    news:...
    > Hi I am working on a web application which will be accessed by
    > thousands of visitors per day, so speed and performance is crucial to
    > the application.
    >
    > One of the business logic classes in my project is now rather big (350
    > lines) and expected to keep growing further and further...
    >
    > It is used in nearly all the webforms.
    >
    > Does its size affect peformance in anyway?
    >
    > Should I be creating more but smaller classes rather than putting most
    > of my methods into one class?
    >
    > Very interested in what people have to say on this.
    >
    > Kind regards,
    >
    > Steve.
    >
    Eliyahu Goldin, Nov 15, 2006
    #2
    1. Advertising

  3. Steve

    Damien Guest

    Steve wrote:

    > Hi I am working on a web application which will be accessed by
    > thousands of visitors per day, so speed and performance is crucial to
    > the application.
    >
    > One of the business logic classes in my project is now rather big (350
    > lines) and expected to keep growing further and further...
    >
    > It is used in nearly all the webforms.
    >
    > Does its size affect peformance in anyway?
    >
    > Should I be creating more but smaller classes rather than putting most
    > of my methods into one class?
    >
    > Very interested in what people have to say on this.
    >
    > Kind regards,
    >
    > Steve.


    Don't optimize until you need to, and then be smart about your
    optimization. The size of the class (and 350 lines doesn't sound
    horrendously big to me) won't have too much effect, unless you're
    saying that the class contains many different and disparate methods
    which are used differently by the different pages. In that case, good
    design would separate the class out into smaller, more cohesive
    classes. If you're not familiar with the terms "coupling" and
    "cohesion", look them up for advice on how to structure your classes.

    Now, onto the optimization. The best way to optimize is to use a
    profiler. If you're in VS2005, I believe there is a built in profiler
    (not sure which editions - fairly sure it isn't in Express). At work,
    I'm working in VS2003 which doesn't have one, so I use a third party
    profiler (ANTS, not sure if there are others). Use it to find your
    hotspots, and optimize those - it's a lot easier than trying to "guess"
    where you can gain performance (both processor- and memory-wise).

    Damien
    Damien, Nov 15, 2006
    #3
  4. Steve

    Steve Guest

    Thanks for the advice. Will take you up on the profiler software.

    Steve.


    Damien wrote:
    > Steve wrote:
    >
    > > Hi I am working on a web application which will be accessed by
    > > thousands of visitors per day, so speed and performance is crucial to
    > > the application.
    > >
    > > One of the business logic classes in my project is now rather big (350
    > > lines) and expected to keep growing further and further...
    > >
    > > It is used in nearly all the webforms.
    > >
    > > Does its size affect peformance in anyway?
    > >
    > > Should I be creating more but smaller classes rather than putting most
    > > of my methods into one class?
    > >
    > > Very interested in what people have to say on this.
    > >
    > > Kind regards,
    > >
    > > Steve.

    >
    > Don't optimize until you need to, and then be smart about your
    > optimization. The size of the class (and 350 lines doesn't sound
    > horrendously big to me) won't have too much effect, unless you're
    > saying that the class contains many different and disparate methods
    > which are used differently by the different pages. In that case, good
    > design would separate the class out into smaller, more cohesive
    > classes. If you're not familiar with the terms "coupling" and
    > "cohesion", look them up for advice on how to structure your classes.
    >
    > Now, onto the optimization. The best way to optimize is to use a
    > profiler. If you're in VS2005, I believe there is a built in profiler
    > (not sure which editions - fairly sure it isn't in Express). At work,
    > I'm working in VS2003 which doesn't have one, so I use a third party
    > profiler (ANTS, not sure if there are others). Use it to find your
    > hotspots, and optimize those - it's a lot easier than trying to "guess"
    > where you can gain performance (both processor- and memory-wise).
    >
    > Damien
    Steve, Nov 15, 2006
    #4
  5. Steve, here's the "thing":

    1) 350 lines is very small. Assemblies are loaded into the appDomain and
    stay there, and they are compiled, so having an assembly containing multiple
    classes that originally had thousands of lines of code each before JITing is
    not a big deal.

    2) From a performance standpoint, you may be better off with a single
    assembly containing more code, than multiple assemblies with less code each.

    3) As already mentioned, you can optimize code by observing best practices
    coding style and using profiling tools.

    Peter

    --
    Co-founder, Eggheadcafe.com developer portal:
    http://www.eggheadcafe.com
    UnBlog:
    http://petesbloggerama.blogspot.com




    "Steve" wrote:

    > Hi I am working on a web application which will be accessed by
    > thousands of visitors per day, so speed and performance is crucial to
    > the application.
    >
    > One of the business logic classes in my project is now rather big (350
    > lines) and expected to keep growing further and further...
    >
    > It is used in nearly all the webforms.
    >
    > Does its size affect peformance in anyway?
    >
    > Should I be creating more but smaller classes rather than putting most
    > of my methods into one class?
    >
    > Very interested in what people have to say on this.
    >
    > Kind regards,
    >
    > Steve.
    >
    >
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Nov 15, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shaguf
    Replies:
    0
    Views:
    326
    Shaguf
    Dec 24, 2008
  2. Shaguf
    Replies:
    0
    Views:
    431
    Shaguf
    Dec 26, 2008
  3. ericnoonan
    Replies:
    0
    Views:
    337
    ericnoonan
    Dec 14, 2009
  4. Shaguf
    Replies:
    0
    Views:
    218
    Shaguf
    Dec 26, 2008
  5. Shaguf
    Replies:
    0
    Views:
    202
    Shaguf
    Dec 24, 2008
Loading...

Share This Page