I am trying to design my render partial. within one render partial i have 30 other render partial functions. I am rendering one item at a time. for example, I am going to put these items in their separate renderpartial function:
- time
- username
- title
- avatar
- tags
- score
- user information — each element has its separate render partial
- and so on
so i am going to organize the render partial functions because there is going to be so many that is going to be on one page. Is this bad practice?
I think it depends: How many lines are in your partial view? There’s no point to refactoring a one-line partial view, which is what it sounds like you’re doing. If I misunderstand, then it would be helpful if you could post some sample code.
I can’t picture why you would want to encapsulate a single line without seeing the line you want to put in a partial view. I’d be careful of premature optimization here. e.g. You probably want something like 3 10-line partial views instead of 30 1-liners.
As far as performance goes, I doubt you’d see a serious performance hit unless you’re deploying on a particularly ancient server or getting very high traffic. So yes, it will definitely be slower than putting everything in a single view because you’re calling a subroutine, but I don’t think it’ll make a real difference to your users.