Welcome Guest, Not a member yet? Register   Sign In
Class naming conventions
#4

[eluser]CroNiX[/eluser]
Don't forget, when CI loads a controller, library or model, it extends the singleton, $this, with the name of the object you are loading. So if you load 2 things with the same name, there will be a collision.

As others mentioned, its common to leave the controller name as clean as you can, since that is what will appear in the url, and then add a suffix to everything else that indicates what it is.

User (controller)
User_model (model)
User_library (library)

Then to access,
$this (when in controller)
$this->user_model (when accessing model from controller)
$this->user_library (when accessing library from controller)

You'll never have a collision and everything will make syntactic sense when viewing the code.


Messages In This Thread
Class naming conventions - by El Forum - 07-19-2012, 05:06 AM
Class naming conventions - by El Forum - 07-19-2012, 05:47 AM
Class naming conventions - by El Forum - 07-19-2012, 03:42 PM
Class naming conventions - by El Forum - 07-19-2012, 04:28 PM
Class naming conventions - by El Forum - 07-19-2012, 05:51 PM
Class naming conventions - by El Forum - 07-19-2012, 08:48 PM
Class naming conventions - by El Forum - 07-19-2012, 11:32 PM
Class naming conventions - by El Forum - 07-20-2012, 07:45 AM



Theme © iAndrew 2016 - Forum software by © MyBB