On Naming things

Wrote an article on naming things. Here it is:

https://en.rmcreative.ru/blog/naming-things/

3 Likes

It reminds me of a long time classic: Guidelines for good schema design

This wiki article is a must-read not only for yii community but also for developers in general. It helped me a lot to understand how good naming matters.

Yes, @SJFriedl nailed it back then.

I think, Yii have serious issue for naming convention

Name of identifier must self expline, don’t need comment in code consumer

  1. inconsisten type of method return.
    for example in AR, find() return Query object but, findOne return AR object
    We must read docs or AR code to understand this
    so I’m wrapping Yii AR ,
    - query() = find()
    - queryBySql() = findBySql()
    - queryByCondition() = findByCondition()
    use query() method instead find() method then all coder will understand that the return is Query object

    ref : https://github.com/poodev/yii2-db/blob/master/src/ActiveRecord.php

  2. name not easy to understand
    for example on RBAC DbManager => method addChild, add child of what?
    if context not specific, then the context is Object that have the method .
    so addChild mean add child of DbManager.

    to fix it, i recomend use addItemChild instead addChild

I think Clean Code by Robert C Martin is good for guideline.

We’re improving it in Yii 3. You can participate as well.