-2

I've been developing a website and instead of having lots of models i've been chaining properties and what not to a single model by populating a prop and returning itself. not very important to the question but

var data = model.withUser(user).withStuff(data)

i'm curious if having a model class with a lot of lines of code will affect performance of the web app?

Thoughts

Steve
  • 25,806
  • 2
  • 33
  • 43

2 Answers2

1

I don't know about performance (you'd have to benchmark one approach versus the other to say for sure), but I can say that having one monolithic class is going to be a pain when it comes to testing and reasoning about how it works.

In general, prefer composition to inheritance (lots of small classes to one large class).

Community
  • 1
  • 1
48klocs
  • 6,073
  • 3
  • 27
  • 34
  • thanks for the comment, but i can't mark this as an answer since you don't answer the question. – Steve Jun 22 '11 at 23:38
0

Well yes... more code to run == more execution time yet we are talking micro and mostly likely nano seconds of time here.

If you are worried about that you are either A. Facebook or B. Google. ;)

John Farrell
  • 24,673
  • 10
  • 77
  • 110
  • it's not more code to run in my scenario. i only use a few props from the class in each view. I guess I was thinking more about webforms and viewstate and if mvc model class size could affect performance the way viewstate did in webforms. – Steve Jun 23 '11 at 15:20