Click here to Skip to main content
15,921,351 members
Home / Discussions / C#
   

C#

 
GeneralRe: How can artificial intelligence response? Pin
Abhinav S22-Apr-10 16:32
Abhinav S22-Apr-10 16:32 
GeneralRe: How can artificial intelligence response? Pin
PIEBALDconsult22-Apr-10 17:05
mvePIEBALDconsult22-Apr-10 17:05 
GeneralRe: How can artificial intelligence response? Pin
OriginalGriff22-Apr-10 21:34
mveOriginalGriff22-Apr-10 21:34 
AnswerRe: How can artificial intelligence response? Pin
Stephen Hewitt22-Apr-10 22:14
Stephen Hewitt22-Apr-10 22:14 
AnswerRe: How can artificial intelligence response? Pin
Pete O'Hanlon22-Apr-10 23:11
mvePete O'Hanlon22-Apr-10 23:11 
GeneralRe: How can artificial intelligence response? Pin
Luc Pattyn22-Apr-10 23:52
sitebuilderLuc Pattyn22-Apr-10 23:52 
AnswerRe: How can artificial intelligence response? Pin
riced23-Apr-10 2:43
riced23-Apr-10 2:43 
QuestionFlight Inquiry Application Pin
Jassim Rahma22-Apr-10 13:28
Jassim Rahma22-Apr-10 13:28 
AnswerRe: Flight Inquiry Application Pin
Lokesh Lal22-Apr-10 17:46
Lokesh Lal22-Apr-10 17:46 
QuestionPlay Video from Csharp Pin
Obaid Ahmed22-Apr-10 11:36
Obaid Ahmed22-Apr-10 11:36 
AnswerRe: Play Video from Csharp Pin
William Winner22-Apr-10 12:20
William Winner22-Apr-10 12:20 
GeneralRe: Play Video from Csharp Pin
Obaid Ahmed22-Apr-10 22:48
Obaid Ahmed22-Apr-10 22:48 
AnswerRe: Play Video from Csharp Pin
Peace ON22-Apr-10 21:22
Peace ON22-Apr-10 21:22 
QuestionExam preparation Pin
netJP12L22-Apr-10 11:03
netJP12L22-Apr-10 11:03 
AnswerRe: Exam preparation Pin
AspDotNetDev22-Apr-10 11:12
protectorAspDotNetDev22-Apr-10 11:12 
AnswerRe: Exam preparation Pin
William Winner22-Apr-10 12:23
William Winner22-Apr-10 12:23 
AnswerRe: Exam preparation Pin
PIEBALDconsult22-Apr-10 13:05
mvePIEBALDconsult22-Apr-10 13:05 
AnswerRe: Exam preparation Pin
yu-jian22-Apr-10 15:42
yu-jian22-Apr-10 15:42 
GeneralRe: Exam preparation Pin
Peace ON22-Apr-10 22:09
Peace ON22-Apr-10 22:09 
AnswerRe: Exam preparation Pin
Peace ON22-Apr-10 22:07
Peace ON22-Apr-10 22:07 
GeneralRe: Exam preparation Pin
netJP12L23-Apr-10 4:43
netJP12L23-Apr-10 4:43 
Questioncomments? Pin
Megidolaon22-Apr-10 10:46
Megidolaon22-Apr-10 10:46 
AnswerRe: comments? Pin
Luc Pattyn22-Apr-10 11:05
sitebuilderLuc Pattyn22-Apr-10 11:05 
AnswerRe: comments? Pin
AspDotNetDev22-Apr-10 11:09
protectorAspDotNetDev22-Apr-10 11:09 
I usually clump things into logical groups, then I toss some comment above that group of code. If it's a simple bit of code, I use a small comment... if it's more complex, I might use a bigger comment. All my methods have comments on them (though some disagree with this practice and only comment public methods). I comment so others will be able to understand the code easily if they come across it later. I also have various practices for how I comment that I've just adopted over time. For example, I typically shove most of the variables at the top of the method and comment that section with:
C#
// Variables.
int x;
Person person;

It's standard for me, so I know when I see that that I can pretty much skip over that section of code. That illustrates another point -- that comments aren't always to describe the code, but have other purposes. In this case, the other purpose is so I know what code to skip over, which speeds up reading the code. For a similar reason, I comment every single property I have. I do this because it avoids an interruption in reading the code... the consistency between each property means there is one less thing my brain has to process when scanning code.

Also, most of the time, you should avoid commenting what the code does and instead comment what the code was made to do. For example, this would be a bad comment:
C#
// Iterates over a list of people and processes each in succession.
foreach(Person p in this.GetPeople())
{
    if(p.Height > Person.AverageHeight)
    {
        tallPeople.Add(p);
    }
    else if(p.Height == Person.AverageHeight)
    {
        averagePeople.Add(p);
    }
    else
    {
        shortPeople.Add(p);
    }
}

A better comment might be:
C#
// Categorize people by their height.
foreach(Person p in this.GetPeople())
{
    if(p.Height > Person.AverageHeight)
    {
        tallPeople.Add(p);
    }
    else if(p.Height == Person.AverageHeight)
    {
        averagePeople.Add(p);
    }
    else
    {
        shortPeople.Add(p);
    }
}

There are other nuances when it comes to commenting code, but you'll develop an intuition for these types of things as time goes on. Whatever system you develop, just follow it consistently.

AnswerRe: comments? Pin
hammerstein0522-Apr-10 11:26
hammerstein0522-Apr-10 11:26 

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.