Click here to Skip to main content
15,910,118 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Coding Standards Pin
Gregory Gadow13-Feb-14 4:16
Gregory Gadow13-Feb-14 4:16 
GeneralRe: Coding Standards Pin
wout de zeeuw13-Feb-14 4:26
wout de zeeuw13-Feb-14 4:26 
GeneralRe: Coding Standards Pin
Member 1008817113-Feb-14 8:54
Member 1008817113-Feb-14 8:54 
GeneralRe: Coding Standards Pin
jschell13-Feb-14 9:12
jschell13-Feb-14 9:12 
GeneralRe: Coding Standards Pin
Member 1008817113-Feb-14 9:35
Member 1008817113-Feb-14 9:35 
GeneralRe: Coding Standards Pin
jschell14-Feb-14 10:16
jschell14-Feb-14 10:16 
GeneralRe: Coding Standards Pin
S Houghtelin13-Feb-14 4:29
professionalS Houghtelin13-Feb-14 4:29 
AnswerRe: Coding Standards Pin
Ravi Bhavnani13-Feb-14 4:39
professionalRavi Bhavnani13-Feb-14 4:39 
I find both these standards odd.

I've been using RCG (Ravi's Commenting Guidelines™) for 20 years and they have served me and my teammates well.  The guidelines are simple:
  1. Strip out all code within blocks (except block delimiters - i.e. if, do, for, while and switch code boundaries).
  2. The remaining code and comments should clearly represent the method's psuedocode.  If it doesn't, you need to add comments.

The coding standard about declaring all local variables at the start of a method is complete nonsense, IMHO.  To maximize readability, local variables should be declared on first use within the block to which they're scoped.

This would cause me to rewrite your example method thusly:
/// <summary>
/// Performs a file copy (a better comment is required here).
/// </summary>
/// <returns>The result of the operation.</returns>
private MyClass MyMethod()
{
    // For each file whose name is less than 21 chars...
    int count = 0;
    foreach (MyFileObj file in _myFileCollection) {
        if (file.Name.Length <= 20) {
            // Copy it to the new location
            file.CopyTo(@"C:\SomePath\" + file.Name);
            count++;
        }
    }
 
    // A lot of other code
    // ...

    // Return result
    MyClass someObj = new MyClass();
    someObj.FileCount = count;
    return someObj;
}
/ravi
My new year resolution: 2048 x 1536
Home | Articles | My .NET bits | Freeware
ravib(at)ravib(dot)com

GeneralRe: Coding Standards Pin
Matt U.13-Feb-14 5:12
Matt U.13-Feb-14 5:12 
GeneralRe: Coding Standards Pin
Dennis E White13-Feb-14 5:23
professionalDennis E White13-Feb-14 5:23 
GeneralRe: Coding Standards Pin
Matt U.13-Feb-14 6:05
Matt U.13-Feb-14 6:05 
GeneralRe: Coding Standards Pin
jschell13-Feb-14 9:07
jschell13-Feb-14 9:07 
GeneralRe: Coding Standards Pin
Matt U.13-Feb-14 10:37
Matt U.13-Feb-14 10:37 
GeneralRe: Coding Standards Pin
Dennis E White13-Feb-14 12:52
professionalDennis E White13-Feb-14 12:52 
GeneralRe: Coding Standards Pin
jschell14-Feb-14 10:06
jschell14-Feb-14 10:06 
GeneralRe: Coding Standards Pin
Matt U.14-Feb-14 10:10
Matt U.14-Feb-14 10:10 
GeneralRe: Coding Standards Pin
_Maxxx_13-Feb-14 16:47
professional_Maxxx_13-Feb-14 16:47 
GeneralRe: Coding Standards Pin
Stefan_Lang14-Feb-14 0:03
Stefan_Lang14-Feb-14 0:03 
GeneralRe: Coding Standards Pin
Stefan_Lang13-Feb-14 23:58
Stefan_Lang13-Feb-14 23:58 
GeneralRe: Coding Standards Pin
User 754579914-Feb-14 3:54
User 754579914-Feb-14 3:54 
GeneralRe: Coding Standards Pin
agolddog14-Feb-14 4:11
agolddog14-Feb-14 4:11 
GeneralRe: Coding Standards Pin
Member 999720314-Feb-14 5:48
Member 999720314-Feb-14 5:48 
GeneralRe: Coding Standards Pin
Ralph Little14-Feb-14 6:10
Ralph Little14-Feb-14 6:10 
GeneralRe: Coding Standards Pin
Kirk 1038982114-Feb-14 8:12
Kirk 1038982114-Feb-14 8:12 
GeneralRe: Coding Standards Pin
Daniel R. Przybylski14-Feb-14 8:21
Daniel R. Przybylski14-Feb-14 8:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.