• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
is it a good practice to load the model in the constructor function??

#4
[eluser]jmadsen[/eluser]
[quote author="EzraBynx" date="1349554444"]I think this is a convenience versus performance issue. If the model is going to be used by most of your controller I would suggest loading the model in the constructor because it offers simplicity. I also feel as though it improves the readability of the code.

Loading to many unneeded resources in the constructor comes at a performance hit.[/quote]

I don't think that's an issue - libraries (which included models) are loaded once, so there would be a brief uptick the first time that controller was hit is all.

I realize it's not quite that simple, but I personally don't concern myself with the performance part of this unless I'm building something that is going to get really pounded. Not that you should ignore best practices, but I would focus on other things to get your best performance (your db sql & interactions, for example)

Keep your code simple and easy to work with


Messages In This Thread
is it a good practice to load the model in the constructor function?? - by El Forum - 10-06-2012, 03:39 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.