|
||||||
| General Programming Non language specific, Assembly, Linux/Unix, Mac and anything not covered in other topics. Talk about Programming Theory here. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
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. |
| Sponsored Links |
|
|
|
|||
|
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. |
|
|||||
|
Quote:
.... I need to change my style now .....
__________________
Lop |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
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 |
| 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 |
Goal: 100,000 Posts
Complete: 82%