Jump to content
MakeWebGames

camelCaseConvention vs underscores_convention?


Script47

camelCaseConvention vs underscores_convention?  

8 members have voted

  1. 1. camelCaseConvention vs underscores_convention?

    • camelCaseConvention
      6
    • underscores_convention
      1
    • Either
      1
    • Other? Please state which one.
      0


Recommended Posts

Personally, it all depends. A lot of the code I write is not for a completely blank website or a blank application. Most of the time, it's adding onto it or fixing problems with said application. So in those cases, my coding convention mimics what is already there in order to keep the coding bases somewhat consistent.

If it is a blank website or my personal site, most of my variables do not even have either of these conventions. A lot of times I make my variables all one word, all lowercase with comments around it explaining what the variable is and what it is used for.

~G7470

Link to comment
Share on other sites

If it is a blank website or my personal site, most of my variables do not even have either of these conventions. A lot of times I make my variables all one word, all lowercase with comments around it explaining what the variable is and what it is used for.

~G7470

I've personally felt that when you have a variable in one long line it is a lot harder to read. Could you show snippets of some of you code if you could please?

Link to comment
Share on other sites

Of course with a name too long, it could greatly effect the readability; however, you can also make the variable names relative to its purpose to improve this issue.

Here's a little snippet from a drug modification mod that I made:

 

	$growdrugres = mysql_query("/* QUERY HERE - LEFT OUT FOR SNIPPET */");
if(mysql_num_rows($growdrugres) > 0) {
	while($drugarr = mysql_fetch_array($growdrugres)) {
		if($drugarr['ending'] < time()) {
			$countdrug = 1;
		}
	}
	if($countdrug == 1) {
		echo "<center><a href='growdrugs.php'><b>Click here to harvest your drugs.</b></a></center>";
	}
}

 

One more, probably the longest variable names I have ever made here from another mod I made:

 

$drivebyconfig = mysql_query("/* QUERY HERE - LEFT OUT FOR SNIPPET */");
$drivebyconfigsettings = mysql_fetch_row($drivebyconfig);
$requiredwep = $drivebyconfigsettings[0];
$requiredarm = $drivebyconfigsettings[1];
$requiredcar = $drivebyconfigsettings[2];

 

~G7470

Link to comment
Share on other sites

Of course with a name too long, it could greatly effect the readability; however, you can also make the variable names relative to its purpose to improve this issue.

Here's a little snippet from a drug modification mod that I made:

 

	$growdrugres = mysql_query("/* QUERY HERE - LEFT OUT FOR SNIPPET */");
if(mysql_num_rows($growdrugres) > 0) {
	while($drugarr = mysql_fetch_array($growdrugres)) {
		if($drugarr['ending'] < time()) {
			$countdrug = 1;
		}
	}
	if($countdrug == 1) {
		echo "<center><a href='growdrugs.php'><b>Click here to harvest your drugs.</b></a></center>";
	}
}

 

One more, probably the longest variable names I have ever made here from another mod I made:

 

$drivebyconfig = mysql_query("/* QUERY HERE - LEFT OUT FOR SNIPPET */");
$drivebyconfigsettings = mysql_fetch_row($drivebyconfig);
$requiredwep = $drivebyconfigsettings[0];
$requiredarm = $drivebyconfigsettings[1];
$requiredcar = $drivebyconfigsettings[2];

 

~G7470

 

Wow, that's so '07 :p

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...