[PHP] Do you have some standard for defined the variable in program language?
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Do you have some standard for defined the variable in program language?
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
Re: [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 a...@ashleysheridan.co.uk 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
Re: [PHP] Do you have some standard for defined the variable in program language?
On 27/07/10 10:42, viraj wrote: $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 I like to use $firstName, and function firstName(), but I would use class FirstName. Somehow in my mind, classes are important enough to earn the initial capital letter. -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] Do you have some standard for defined the variable in program language?
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 kali...@gmail.com To: a...@ashleysheridan.co.uk a...@ashleysheridan.co.uk 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 a...@ashleysheridan.co.uk 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[2]: [PHP] Do you have some standard for defined the variable in program language?
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 an...@oire.org 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 kali...@gmail.com To: a...@ashleysheridan.co.uk a...@ashleysheridan.co.uk 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 a...@ashleysheridan.co.uk 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[2]: [PHP] Do you have some standard for defined the variable in program language?
On 27 July 2010 13:04, viraj kali...@gmail.com wrote: so, this is another reason to avoid 'underscore' in variable names. code looks prettier and clean. That's all in the eye of the viewer: underscores are much prettier to me in variables. That's all just a roundabout way of saying it's prettier has no meaning on an objective level. classes - MyBestClass functions - TheGreatestFunctionInTheWorld That confuses classes and functions - I prefer a naming convention where classes and functions are named using different styles. Personally I go for mixed-case for classes and camelcase for functions, e.g. MyClass and myFunction(). Still, that's really just personal taste and whatever makes you happy is the thing to go with. Regards Peter -- hype WWW: http://plphp.dk / http://plind.dk LinkedIn: http://www.linkedin.com/in/plind BeWelcome/Couchsurfing: Fake51 Twitter: http://twitter.com/kafe15 /hype -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Do you have some standard for defined the variable in program language?
At 3:12 PM +0530 7/27/10, viraj wrote: $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 I like using $first_name. I don't have any problems with using that convention for method/function/class names. The only problem I have found (regardless of naming convention) is in using $_SESSION[]'s. Sometimes: $first_name = $_SESSION['first_name.']; will cause problems. The solution is to use an index that's named different than the variable name, such as: $first_name = $_SESSION['session_first_name.']; Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] Do you have some standard for defined the variable in program language?
At 1:38 PM +0300 7/27/10, Andre Polykanine wrote: Hello viraj, As for classes, it's suggested to start a class name with a capital: class MyBestClass { ... } In some languages (I can't remember if it is Java, or Javascript, or both) the first letter should be lowercase, such as: myBestClass Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[2]: [PHP] Do you have some standard for defined the variable in program language?
Tedd- Java has classes listed with an Uppercase. It could be JS you're thinking of but I'm not sure. Functions (except constructors) and variables have the lowerUpperCamelCase notation. Regards, -Josh On Jul 27, 2010, at 12:55 PM, tedd wrote: At 1:38 PM +0300 7/27/10, Andre Polykanine wrote: Hello viraj, As for classes, it's suggested to start a class name with a capital: class MyBestClass { ... } In some languages (I can't remember if it is Java, or Javascript, or both) the first letter should be lowercase, such as: myBestClass Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: Re[2]: [PHP] Do you have some standard for defined the variable in program language?
From: tedd At 1:38 PM +0300 7/27/10, Andre Polykanine wrote: Hello viraj, As for classes, it's suggested to start a class name with a capital: class MyBestClass { ... } In some languages (I can't remember if it is Java, or Javascript, or both) the first letter should be lowercase, such as: myBestClass One of the best features of standards is that there are so many to choose from. Likewise with coding styles, there are nearly as many as there are coders. If you are working by yourself, pick something and stick with it. If you are working in a group, or are employed to write code, there may be requirements agreed upon or required in that environment. You may not find out about them until your first code review, but be assured, you will eventually be told about them. Bob McConnell -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Do you have some standard for defined the variable in program language?
On 7/27/2010 12:38 PM, Andre Polykanine 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. Hello All First thanks for all suggestions, I find some document from 2003 year and plane to use this standard everybody who what can see on next link http://www.dagbladet.no/development/phpcodingstandard/ Best Regards Jovanov Jordan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Do you have some standard for defined the variable in program language?
Some style guides you might find interesting (the Code Igniter style guide might be the most relevant to this discussion): Django: Coding style http://tinyurl.com/bn8jv8 ExpressionEngine: General Style and Syntax http://tinyurl.com/dfh7fa Flex: SDK coding conventions and best practices http://tinyurl.com/3xphtd CodeIgniter (EE 2.0 core framework): User Guide Version 1.7.2 General Style and Syntax http://snipurl.com/t32db Python: Style Guide for Python Code http://snipurl.com/zwfvo Hths. Micky -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php