gbasto
(Goncalo Basto)
January 25, 2013, 9:50am
1
Hi,
I was reading the Yii 2 coding style and the following caught my attention:
[color="#333333 "][font="Helvetica, arial, freesans, clean, sans-serif"] [/font][/color]
[color="#333333 "][font=“Helvetica, arial, freesans, clean, sans-serif”][size=“4”]Class names MUST be declared in [/size][/font][/color]StudlyCaps[color="#333333 "][font=“Helvetica, arial, freesans, clean, sans-serif”][size=“4”]. Core classes should be prefixed with [/size][/font][/color]C[color="#333333 "][font=“Helvetica, arial, freesans, clean, sans-serif”][size=“4”]. For example, [/size][/font][/color]CController[color="#333333 "][font=“Helvetica, arial, freesans, clean, sans-serif”][size=“4”], [/size][/font][/color]CWidget[color="#333333 "][font=“Helvetica, arial, freesans, clean, sans-serif”][size=“4”]. Application and extension classes should not use [/size][/font][/color]C[color="#333333 "][font=“Helvetica, arial, freesans, clean, sans-serif”][size=“4”] as prefix. For extensions it’s common to use [/size][/font][/color]E[color="#333333 "][font=“Helvetica, arial, freesans, clean, sans-serif”][size=“4”].[/size][/font][/color]
[color="#333333 "][font="Helvetica, arial, freesans, clean, sans-serif"] [/font][/color]
My question is… is still necessary the class names prefixes once we have namespaces? Why use CClass, EClass or Class if we are able to have \yii\Class, \extension\Class or \app\Class / \Class?
Cheers.
sx9
(Sx9)
January 25, 2013, 1:54pm
2
In the example code posted by qiang the "C" prefix is not used, so I guess not. However the "E"-prefix could be usefull for extensions.
samdark
(Alexander Makarov)
January 25, 2013, 7:52pm
3
Thanks. Fixed. That page is a draft I’ve started putting up together but haven’t finished yet.
gbasto
(Goncalo Basto)
January 28, 2013, 10:11am
4
[size=2]No problem. Congrats for the great work done so far. [/size]