Model Variable Naming Convention

Hello,

I’ve recently started to explore the framework and I like what I see!

I have a question about variable naming conventions in controllers and views when referencing models. In most of the tutorials and a few of the extensions I’ve looked at, the model is named $model. Being an MVC pattern, I can understand why but personally it does not feel right. So far I’ve been naming my variables as per the model name, e.g. $person or $account.

What is considered best practice, and why? $model seems to make sense up to the point where you end up referencing multiple models in a view or controller, then you’re forced to call the second one something else.

Thoughts?

Regards

http://www.yiiframework.com/wiki/227/guidelines-for-good-schema-design/

Hello,

Thanks for the link, but it doesn’t answer my question. Perhaps you misunderstood; I am not seeking clarity on model naming conventions, but the variable naming convention when referencing a model.

Thanks

when I create a new Person, I call the variable $person, because several screens down it is still a person and you know it

That certainly seems more natural to me. I just found it interesting that a lot of the tutorials (and user-contributed extensions) call models $models, and I started to wonder whether there was a best practice.

Thanks