• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Autoloading Models PHP 5 Style

#11
[eluser]Thomas Lee Brewer Jr.[/eluser]
[quote author="Phil Sturgeon" date="1262185535"]I was just posting a comment on that article, point out how bad this (very old and commonly known) idea is.

Quote:1. The model when loaded will not be added to the CodeIgniter super-global unless you do $this->post = new Post; which will kill the shorter syntax.

2. The model will need to be loaded in each model, library or method it is used.

3. By not inheriting from Model you will have no access to loaded libraries without using $ci =& get_instance() which will make your models look ugly as sin.

And I share umefarooq's concern, if you ever need to call a controller directly you are doing something very wrong and the MVC Gods will punish you. Tongue[/quote]


Responses:
1. Who said Globals are a good design pattern?
2. No. Not sure how you are getting that.
3. Why would you not inherit from Model or another superclass that provides similar functionality?

Autoloading is not bad. Just not understood by some. Not using autoloading is a premature optimization.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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