Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8709093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:17:03+00:00 2026-06-13T04:17:03+00:00

I recently read an old article it which this was suggested Avoid using the

  • 0

I recently read an old article it which this was suggested

Avoid using the $uses array
You’ve got two completely unrelated models, but you need info from one in the controller of another. The
first idea is to add them to the $uses array. Hey, it’s easy and gets
the job done. Well, to make the long story short, it’s bad practice.
Think about your model bindings and ensure that models are really not
related to one another. Sometimes your User model is definitely not
related to CommentRating, but you absolutely need it in your users
controller. Well, just by chance it appears that
User->Post->Comment->CommentRating. It’s a deep binding that may not
be obvious at first, but by employing such a chain of models you can
easily avoid using the $uses array, when it’s really not necessary.

For the sake of readability/maintainability, I tend to prefer putting CommentRating in the uses array and then calling $this->CommentRating directly.

Is using the $uses array really bad practice and if so why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:17:05+00:00Added an answer on June 13, 2026 at 4:17 am

    That quote cuts a long story a bit too short. Why is it a bad practice? He doesn’t even give one reason. I wouldn’t pay too much attention to it.

    I’m no expert, but there are definitely cases when readability and common sense in your code is more important than a minute performance increase or whatever else avoiding $uses may provide. I’ll be continuing to use $uses instead of obscure model chains like User->Post->Comment->Rating

    EDIT: And as @tigrang added, with lazy loading of Models in Cake 2, there’s not really a performance benefit anyway!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently read this thread on MSDN . So I was thinking of using
I recently read this article Safe Thread Synchronization as I was curious about the
I recently read an article about password hashing . How are MD5 or SHA1
I recently read a blog in Nodejitsu and I am wondering how this piece
I recently read a post online about rotating text with css. This appealed to
I recently read an article about c#-5 and new & nice asynchronous programming features
Recently read in a article on dotnetpearls.com here saying that static ctors take a
I recently installed IE8, and found quirks using the old copies of IE I
I recently read Object Oriented Exception Handling in Perl Perl.com article. Is there any
We've got a legacy app (VB6) which works fine on an old Windows Server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.