When I create an application using YIIC, every new file it seems uses the variable $model. This makes reading the code an unhappy task.
While reading the Blog tutorial, it can be seen that a saner variable naming method is used, eg. if I am working with the CommentController and comment class, these use the varible $comment. If I am working with PostController and post class then the variable is $post, if UserController and user class then $user.
Why is this convention not used, when your own tutorial points to this being a far better naming convention? With $model all over the place it is very difficult to keep track of things that would be very simple using unique variable names based on the name of the controller/model.
Page 1 of 1
$model Same variable everywhere
#2
Posted 03 August 2009 - 01:48 PM
i think you're speaking about the generated code by yiic tool.
so, it might be just some a way that the coder did when he/she was creating the script.
it doesn't mean that you don't have to follow a code convention.
you can follow a different and more readble convention just by renaming the variable that will be set via controller.
so, it might be just some a way that the coder did when he/she was creating the script.
it doesn't mean that you don't have to follow a code convention.
you can follow a different and more readble convention just by renaming the variable that will be set via controller.
Backslider, on 02 August 2009 - 11:37 PM, said:
When I create an application using YIIC, every new file it seems uses the variable $model. This makes reading the code an unhappy task.
While reading the Blog tutorial, it can be seen that a saner variable naming method is used, eg. if I am working with the CommentController and comment class, these use the varible $comment. If I am working with PostController and post class then the variable is $post, if UserController and user class then $user.
Why is this convention not used, when your own tutorial points to this being a far better naming convention? With $model all over the place it is very difficult to keep track of things that would be very simple using unique variable names based on the name of the controller/model.
While reading the Blog tutorial, it can be seen that a saner variable naming method is used, eg. if I am working with the CommentController and comment class, these use the varible $comment. If I am working with PostController and post class then the variable is $post, if UserController and user class then $user.
Why is this convention not used, when your own tutorial points to this being a far better naming convention? With $model all over the place it is very difficult to keep track of things that would be very simple using unique variable names based on the name of the controller/model.
"no one person is smart enough or has enough knowledge to figure out everything without assistance"
#3
Posted 03 August 2009 - 07:40 PM
Yes, clearly I am talking about the YIIC tool.
My question is also clearly directed toward the developers
My question is also clearly directed toward the developers
#4
Posted 04 August 2009 - 01:56 PM
The reason for using $model is that it is independent of the model name. As a result, it is more likely that you can "reuse" your views.
#5
Posted 04 August 2009 - 07:47 PM
Ok, that makes sense.
Any chance of the blog tutorial being updated accordingly?
Any chance of the blog tutorial being updated accordingly?
Share this topic:
Page 1 of 1

Help














