Lost Password?

Go Back   CodeCall Programming Forum > Software Development > General Programming

Unregistered, Check out the Coder Battles in the Announcement and Game forums.

General Programming Non language specific, Assembly, Linux/Unix, Mac and anything not covered in other topics. Talk about Programming Theory here.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-28-2006, 12:19 PM
RobSoftware RobSoftware is offline
Programmer
 
Join Date: Nov 2005
Posts: 143
Credits: 0
Rep Power: 11
RobSoftware is on a distinguished road
Default More Coding Methods

From the other thread in this forum we got "The One True Brace" as a brace style and another type (I forget the name of that one). What about variables? I name my variables by capping the second word and each word after that such as:

$myVariable
int myVariable
int myVeryLongVariable

I notice people often use different styles or in really bad coding, no styles.

I often see all words capped.
$MyVariable
int MyVariable

and in bad coding
myVariable
int MyVeryLongVariable (notice the first word isn't capped and then capped?)

My question is: What are these styles called and which do you use? Is there a correct way because I've taken several programming classes and read even more books. Each teacher/author will have a different style.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 05-30-2006, 02:13 PM
brackett brackett is offline
Programmer
 
Join Date: May 2006
Posts: 193
Credits: 0
Rep Power: 10
brackett is on a distinguished road
Default

IME, the first style is called camelCase, and the second PascalCase. Note that this Wikipedia article, however, says they are both camel case and should be called lowerCamelCase or UpperCamelCase (edit: that used to say UpperPascalCase, which is wrong...oops). I say I've never heard of such terms - but do realize that wiki engines in general call PascalCase camelCase. I submit the .NET Framework Design Guidelines on Capitalization in my defense.

For .NET, Microsoft has the above design guideline for the BCL. I'm sure Java has something similar. It's probably advisable to follow those guidelines, so here's the relevant portions of the .NET one:
a. camelCase for parameters, local and (non public) member variables
b. PascalCase for classes, enum types and values, properties, functions, events, readonly statics, public member variables, interfaces, namespaces, and acronyms more than 2 letters long
c. no Hungarian notation
d. no prefix for member variables (I'm not entirely sure this is in there, I know it recommends against underscores for class names, but others have stated it does as well for member variables. I do know, however, that you cannot be CLS compliant with an underscore prefix)

And, now that I have given the "official" recommendation, here's how I actually do it for both VB.NET and C#:
a. camelCase for local variables and parameters
b. PascalCase for pretty much everything else
c. _camelCase (camelCase with a leading underscore) for private or protected member variables
d. ALL_CAPS_WITH_UNDERSCORE for constants
e. Hungarian notation only for web or WinForm control variables

IOW, it's a strange mix of .NET guidelines and my own peculiariaties. Oh well, at least I'm consistent.

Last edited by brackett; 05-30-2006 at 06:06 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-30-2006, 04:42 PM
Lop's Avatar   
Lop Lop is offline
Speaks fluent binary
 
Join Date: May 2006
Posts: 1,149
Credits: 112
Rep Power: 16
Lop will become famous soon enough
Default

Quote:
Originally Posted by brackett
IME, the first style is called camelCase, and the second PascalCase. Note that this Wikipedia article, however, says they are both camel case and should be called lowerCamelCase or UpperPascalCase. I say I've never heard of such terms - but do realize that wiki engines in general call PascalCase camelCase. I submit the .NET Framework Design Guidelines on Capitalization in my defense.

For .NET, Microsoft has the above design guideline for the BCL. I'm sure Java has something similar. It's probably advisable to follow those guidelines, so here's the relevant portions of the .NET one:
a. camelCase for parameters, local and (non public) member variables
b. PascalCase for classes, enum types and values, properties, functions, events, readonly statics, public member variables, interfaces, namespaces, and acronyms more than 2 letters long
c. no Hungarian notation
d. no prefix for member variables (I'm not entirely sure this is in there, I know it recommends against underscores for class names, but others have stated it does as well for member variables. I do know, however, that you cannot be CLS compliant with an underscore prefix)

And, now that I have given the "official" recommendation, here's how I actually do it for both VB.NET and C#:
a. camelCase for local variables and parameters
b. PascalCase for pretty much everything else
c. _camelCase (camelCase with a leading underscore) for private or protected member variables
d. ALL_CAPS_WITH_UNDERSCORE for constants
e. Hungarian notation only for web or WinForm control variables

IOW, it's a strange mix of .NET guidelines and my own peculiariaties. Oh well, at least I'm consistent.
Wow, nice post. I've never done it so. I've always just used CamelCase (Upper) or PascalCode for everything. I guess each person should read up and then default to their own style.

.... I need to change my style now .....
__________________
Lop
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
New Anti-Cheat Community needs coding help avguste PHP Forum 8 04-04-2008 04:42 PM
Coding a stock ticker accessing an asp DB gtg100i General Programming 2 12-10-2006 09:33 AM
Classes, Methods, and Objects Sionofdarkness Java Help 6 08-21-2006 12:55 PM
Coding Methods Lop General Programming 10 07-14-2006 10:03 AM
How long have you been coding php? cpvr PHP Forum 11 07-11-2006 12:41 PM


All times are GMT -5. The time now is 07:41 PM.

Contest Stats

Xav ........ 1333.07
MeTh0Dz|Reb0rn ........ 1055.7
John ........ 881.37
morefood2001 ........ 879.43
marwex89 ........ 869.98
WingedPanther ........ 851.68
Brandon W ........ 757.44
chili5 ........ 312.39
Steve.L ........ 247.05
dcs ........ 219.87

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 82%

Ads