Re: Re[2]: [PHP] Do you have some standard for defined the variable in program language?

[email protected] (viraj)
Newsgroups php.general
Message-ID <[email protected]>
yes andre, and in addition.. i have found the 'underscore' becomes a
handy delimiter character in certain cases. it's really helpful in
auto-loading and in calling user functions and in magic calls.

so, this is another reason to avoid 'underscore' in variable names.
code looks prettier and clean.

variables - $firstName
classes - MyBestClass
functions - TheGreatestFunctionInTheWorld
classes (auto-loadable) - Service_Maps (eg: maps class in service module)

hope this makes a neat coding style.

~viraj

On Tue, Jul 27, 2010 at 4:08 PM, Andre Polykanine <[email protected]> wrote:
> Hello viraj,
>
> As for classes, it's suggested to start a class name with a capital:
> class MyBestClass {
> ...
> }
>
> As for functions and class methods, there are lots of people who name
> them like this:
>
> function the_greatest_function_in_the_world () {
> ...
> }
>
> Maybe it's readable and great, but I have a little problem: I'm using
> a screenreader, so the word "underscore" (and its Russian equivalent)
> is too long for me. So I prefer
>
> function TheGreatestFunctionInTheWorld () {
> ...
> }
>
> However, just discussed it with my wife. She prefers the same method
> as me, though she doesn't use any screenreading software for
> developing.
>
> --
> With best regards from Ukraine,
> Andre
> Skype: Francophile
> Twitter: http://twitter.com/m_elensule
>
> ----- Original message -----
> From: viraj <[email protected]>
> To: [email protected] <[email protected]>
> Date: Tuesday, July 27, 2010, 12:42:36 PM
> Subject: [PHP] Do you have some standard for defined the variable in  program language?
>
> $firstName is the most readable.. for variables.
>
> does anybody have negative thoughts on using the same naming format
> for method/function and for class names?
>
> i guess it's worth sharing! many thanks!
>
> ~viraj
>
> On Tue, Jul 27, 2010 at 3:02 PM, Ashley Sheridan
> <[email protected]> wrote:
>> On Tue, 2010-07-27 at 10:10 +0200, Jordan Jovanov wrote:
>>
>>> Hello Everybody
>>>
>>> I start to write PHP script and all veritable a defined without some
>>> rules. I want to ask to you somebody know how is correct do different
>>> some variable.
>>>   Like from next three variable who is correct:
>>> $firstname  $FirstName $firstName $first_name etc.
>>>
>>> I know that from this variable can work all, but i want to know how is
>>> use in company.
>>> Do you have some standard for defined the variable in program language?
>>> (like ISO9001, ISO14001)
>>>
>>> Best Regard,
>>> Jordan Jovanov
>>>
>>
>>
>> There is no enforced standard on how you define your variable names in
>> PHP. However, you should try and remain consistent with whichever way
>> you decide to use. Personally, I find the $firstName style the best of
>> the four examples you gave. It's easily readable when I look over code
>> at a later date, and slightly faster to type than $first_name (although
>> even if only by a mere fraction of a second!)
>>
>> Some existing codebases might use a particular method though, and if
>> you're working on a project with a team, then it really helps to all be
>> using the same convention of naming variables.
>>
>> At the end of the day, this is all down to preference, along with code
>> indentation and layout.
>>
>> Thanks,
>> Ash
>> http://www.ashleysheridan.co.uk
>>
>>
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.