Welcome Guest, Not a member yet? Register   Sign In
Why CI3 requires ucfirst-case names for all classes?
#9

(03-05-2015, 11:06 AM)Narf Wrote:
(03-05-2015, 08:12 AM)Maximw Wrote: If you know, could you tell me, please, why this convention was accepted only in CI3, but CI2 works excellently without it? Which problems does this convention solve?

In short: it's a way simpler convention than the one CI2 had, allows us to achieve higher performance and an easier autoloader implementation in the future.

It doesn't look like the speed is improved by this change. Comparing system/core/Loader.php::model in CI2 and CI3 doesn't show any possible speed improvement.

CI2 does:

$model = strtolower($model);
require_once($mod_path.'models/'.$path.$model.'.php');
$model = ucfirst($model);
$CI->$name = new $model();

while CI3 does:

$model = ucfirst(strtolower($model));
require_once($mod_path.'models/'.$path.$model.'.php');
$CI->$name = new $model();

The ucfirst convention is unusual on Linux systems and it is annoying to type a file name with an uppercase when opening the file in vim or a terminal (that's what prompted me to reply to this thread now).

On the other hand, Windows and Mac users feel more at home because they open files with mouse clicks (so they don't care about upper/lower cases) and (if I remember right) Windows creates new files with an uppercase as the first character.

So, if you use Linux and think the ucfirst naming convention is odd and inconsistently applied in CI3, remember your OS is less than 2% of the market share.
Reply


Messages In This Thread
RE: Why CI3 requires ucfirst-case names for all classes? - by fmarchal - 04-28-2015, 02:34 AM



Theme © iAndrew 2016 - Forum software by © MyBB