Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

So this means I should stop using CakePHP

I always strongly advise not using CakePHP, purely because its model system is so broken, it makes my teeth itch.



How is it broken?


How is it broken?

All data is returned as an associative array, so there is no way to call something like:

  $cows = $this->Cows->findByStatus(COW_STATUS_NOT_MOOING);
  foreach($cows as $cow)
  {
     $cow->moo();
  }
But that's pretty minor.

The big issue is: all data is returned as an associate array! There is no lazy-loading of the data as you e.g. seek through it, which means it's very easy for people to pass around huge arrays with thousands upon thousands of rows and associations without even thinking about it.

/rant over


I don't use Cake, so don't read this is a defence of Cake.

Lazy loading seems to me a kludge trying to fix poor SQL querying. If you can filter at the app layer, why not pass the information down and filter at the DB layer? You'll be transferring less data and may even read less data from disk (with proper indexes)


Lazy loading seems to me a kludge trying to fix poor SQL querying.

I very much agree with you, lazy loading should not be used as substitute for only querying and/or filtering the data you actually need.

However, there's always going to be a minimum; eventually, the data needs to be processed or displayed! Why load all of it immediately into memory (and potentially pass that around), rather than when it's actually needed?

I think of it a bit like using pointers; passing around the location of the data, rather than the data itself, makes life good for all concerned.

I don't use Cake, so don't read this is a defence of Cake.

Thanks for the disclaimer, as I'm guessing you've experienced before, it's all too easy to get into accidental flamewars about this stuff :)




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: