Click here to Skip to main content
15,904,500 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to sleep the thread in this example? Pin
Luc Pattyn3-Jun-12 4:57
sitebuilderLuc Pattyn3-Jun-12 4:57 
AnswerRe: How to sleep the thread in this example? Pin
daCrazyDude6-Jun-12 15:48
daCrazyDude6-Jun-12 15:48 
Questioncombine edits Pin
dcof2-Jun-12 16:27
dcof2-Jun-12 16:27 
AnswerRe: combine edits Pin
OriginalGriff3-Jun-12 0:27
mveOriginalGriff3-Jun-12 0:27 
GeneralRe: combine edits Pin
dcof3-Jun-12 18:04
dcof3-Jun-12 18:04 
AnswerRe: combine edits Pin
Paul Conrad4-Jun-12 6:38
professionalPaul Conrad4-Jun-12 6:38 
AnswerRe: combine edits Pin
Luc Pattyn3-Jun-12 4:58
sitebuilderLuc Pattyn3-Jun-12 4:58 
Questionbst Pin
negar parham2-Jun-12 7:02
negar parham2-Jun-12 7:02 
AnswerRe: bst Pin
Paul Conrad2-Jun-12 7:07
professionalPaul Conrad2-Jun-12 7:07 
AnswerRe: bst Pin
AmitGajjar4-Jun-12 2:11
professionalAmitGajjar4-Jun-12 2:11 
QuestionC# working with strings Pin
dcof2-Jun-12 6:48
dcof2-Jun-12 6:48 
AnswerRe: C# working with strings Pin
Paul Conrad2-Jun-12 7:02
professionalPaul Conrad2-Jun-12 7:02 
AnswerRe: C# working with strings Pin
OriginalGriff2-Jun-12 9:01
mveOriginalGriff2-Jun-12 9:01 
Questionsend SMS in C# Pin
sina rahimzadeh1-Jun-12 21:48
sina rahimzadeh1-Jun-12 21:48 
AnswerRe: send SMS in C# Pin
Richard MacCutchan1-Jun-12 22:32
mveRichard MacCutchan1-Jun-12 22:32 
AnswerRe: send SMS in C# Pin
Sander Rossel2-Jun-12 0:43
professionalSander Rossel2-Jun-12 0:43 
AnswerRe: send SMS in C# Pin
taha bahraminezhad Jooneghani3-Jun-12 1:56
taha bahraminezhad Jooneghani3-Jun-12 1:56 
QuestionHow to hold dice in yahtzee Pin
Member 83368481-Jun-12 16:05
Member 83368481-Jun-12 16:05 
AnswerRe: How to hold dice in yahtzee Pin
sina rahimzadeh1-Jun-12 21:46
sina rahimzadeh1-Jun-12 21:46 
GeneralRe: How to hold dice in yahtzee Pin
Member 83368481-Jun-12 23:18
Member 83368481-Jun-12 23:18 
QuestionEntity Framework Problem Pin
Kevin Marois1-Jun-12 14:31
professionalKevin Marois1-Jun-12 14:31 
AnswerRe: Entity Framework Problem Pin
Unnikrishnan_S_N9-Jul-12 5:26
Unnikrishnan_S_N9-Jul-12 5:26 
RantVariable Names In Various Projects (Not My Own) Pin
Matt U.1-Jun-12 5:12
Matt U.1-Jun-12 5:12 
I hope this is the correct place to post this. If not, please help me correct it. Poke tongue | ;-P

Lately, I have been digging around in open source projects at SourceForge.net. I download the source for an interesting project, typically if it seems like something I may learn from. I may be working on a project in which I need to create a custom control and I would like a good code example that I can study. Once the source is downloaded and I extract it as needed, I load the solution in Visual Studio 2010.

Once I begin digging through some of the code my head begins to hurt. It hurts terribly. For one, I see little white space in many projects. And two, the thing that really gets me, is the fact that variables have completely meaningless names, usually just one or two letters. It looks like this (not real code; just an example):

C#
// Somewhere else in the code; maybe in a different file, even
Dictionary<string, int> d = new Dictionary<string, int>();

// In some class
private void MyMethod(string p, int q)
{
    bool b = p == "string1" ? true : false;
    List<string> l = GetList(b);
    foreach (string k in l)
    {
        if (!string.IsNullOrWhiteSpace(p) && q > 0)    // new item
            d.Add(l, q);
    }
}


Before I continue, what does the fact that p == "string1" have to do with anything? Also, what does GetList(bool) do and how does the value of 'b' affect the results?

The first thing I tend to notice is that there is no documentation (///<summary>) for the method. Adding those comments too methods and classes is typically the first thing I do when I am coding. Maybe it isn't a recommended practice but instead it is just my own "standard"/style? If so, that's fine. Should this be something everyone uses?

The comments are typically quite vague as well. Or comments are missing entirely, even in methods that contain a lot of code. And in MyMethod, how should you really know what "d" is when it is declared in another file/class? And why exactly does "q > 0" have to be met before adding the item? This isn't a perfect example but I'm not on the computer I use when browsing through these projects. Perhaps I am being overly conscious about coding practices, standards, whatever. But I find it very difficult to read the code at times.

Another thing that bugs me slightly, though I guess it's expected when anyone can contribute to the project, is the lack of a consistent coding style. That doesn't bug me near as much as the rest. It's just a thought that I figured I'd throw in here.
djj55: Nice but may have a permission problem
Pete O'Hanlon: He has my permission to run it.

GeneralRe: Variable Names In Various Projects (Not My Own) Pin
Luc Pattyn1-Jun-12 5:57
sitebuilderLuc Pattyn1-Jun-12 5:57 
GeneralRe: Variable Names In Various Projects (Not My Own) Pin
PIEBALDconsult1-Jun-12 6:03
mvePIEBALDconsult1-Jun-12 6:03 

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.