Performance: Why models represent data
MEDIUM IMPACT
This concept affects how efficiently data is managed and accessed in a Rails application, impacting server response time and page load speed.
def user_name
@user ||= User.find(params[:id])
@user.name
enddef user_name
User.find(params[:id]).name
end| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Repeated database calls without caching | N/A | N/A | Blocks rendering due to slow server response | [X] Bad |
| Model caching with memoization | N/A | N/A | Faster server response enables quicker paint | [OK] Good |