Welcome Guest, Not a member yet? Register   Sign In
The Controlller and Model same filename -> wrong ?
#12

[eluser]slowgary[/eluser]
[quote author="jedd" date="1239213288"]Snoob, Kromack, et al

If you're new to CI, and especially if you're new(ish) to PHP, you should probably avoid renaming Models in this way - it's likely to lead to confusion.

I think a superior approach is to spend a moment more on the design of your system - remember that Controllers are your user-facing component, and each should reflect and encapsulate the functions of a resource within your system. Your Models are your interface to your data, and should reflect the way your models will need to retrieve, store and modify that data. Yes, there are times that these two things are in perfect alignment, but it's not a requirement that they are, and it's often easier to conceptualise things if you keep the two goals, or intents, of Models and Controllers in mind.

It is also an excellent way of avoiding nomenclature clashes. User is the most frequent one that people stumble over. I find the '_model' or '_mdl' suffix feels cumbersome. I've found that thinking of users as People or Members makes things easier, as I can still have a users table (and maybe a model to manage that table), and my People/Member/etc controller will then manage the human related aspects of my site.

Just a different response to the problem of having a User controller, and a User_model model that you rename to User.[/quote]

Jedd, could you give us some examples?

I've been naming my models '_model' for lack of a better method, but it feels wrong for several reasons. One being that it implies a direct relationship between the model and similarly named controller, which is true, but sometimes several controllers may refer to the same model.


Messages In This Thread
The Controlller and Model same filename -> wrong ? - by El Forum - 04-08-2009, 03:48 AM
The Controlller and Model same filename -> wrong ? - by El Forum - 04-08-2009, 04:04 AM
The Controlller and Model same filename -> wrong ? - by El Forum - 04-08-2009, 04:21 AM
The Controlller and Model same filename -> wrong ? - by El Forum - 04-08-2009, 06:30 AM
The Controlller and Model same filename -> wrong ? - by El Forum - 04-08-2009, 06:39 AM
The Controlller and Model same filename -> wrong ? - by El Forum - 04-08-2009, 06:54 AM
The Controlller and Model same filename -> wrong ? - by El Forum - 04-08-2009, 07:04 AM
The Controlller and Model same filename -> wrong ? - by El Forum - 04-08-2009, 07:10 AM
The Controlller and Model same filename -> wrong ? - by El Forum - 04-08-2009, 07:25 AM
The Controlller and Model same filename -> wrong ? - by El Forum - 04-08-2009, 08:24 AM
The Controlller and Model same filename -> wrong ? - by El Forum - 04-08-2009, 09:13 AM
The Controlller and Model same filename -> wrong ? - by El Forum - 05-10-2009, 01:42 PM
The Controlller and Model same filename -> wrong ? - by El Forum - 05-10-2009, 01:58 PM
The Controlller and Model same filename -> wrong ? - by El Forum - 05-10-2009, 02:15 PM
The Controlller and Model same filename -> wrong ? - by El Forum - 05-10-2009, 05:45 PM
The Controlller and Model same filename -> wrong ? - by El Forum - 05-11-2009, 01:38 AM
The Controlller and Model same filename -> wrong ? - by El Forum - 05-11-2009, 07:51 AM
The Controlller and Model same filename -> wrong ? - by El Forum - 05-11-2009, 08:10 AM
The Controlller and Model same filename -> wrong ? - by El Forum - 05-11-2009, 08:33 AM
The Controlller and Model same filename -> wrong ? - by El Forum - 05-11-2009, 08:45 AM
The Controlller and Model same filename -> wrong ? - by El Forum - 05-11-2009, 08:55 AM
The Controlller and Model same filename -> wrong ? - by El Forum - 05-11-2009, 09:04 AM
The Controlller and Model same filename -> wrong ? - by El Forum - 05-11-2009, 09:14 AM
The Controlller and Model same filename -> wrong ? - by El Forum - 05-11-2009, 09:26 AM
The Controlller and Model same filename -> wrong ? - by El Forum - 05-11-2009, 12:28 PM
The Controlller and Model same filename -> wrong ? - by El Forum - 05-11-2009, 01:19 PM
The Controlller and Model same filename -> wrong ? - by El Forum - 05-11-2009, 04:47 PM
The Controlller and Model same filename -> wrong ? - by El Forum - 05-12-2009, 10:11 AM



Theme © iAndrew 2016 - Forum software by © MyBB