Welcome Guest, Not a member yet? Register   Sign In
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



Theme © iAndrew 2016 - Forum software by © MyBB