Tagged Questions
3
votes
3answers
417 views
When are chained assignments (i.e. a=b=c) bad form?
I'm working on a VB.Net WinForms project and found myself writing code like this:
this.Fizz.Enabled = this.Buzz.Enabled = someCondition;
I couldn't decide whether that was bad code or not. Are ...
12
votes
8answers
2k views
Why are people so strongly opposed to #region tags in methods?
I hear a lot about keeping methods short and I've heard a lot of programmers say that using #region tags within a method is a sure sign that it is too long and should be refactored into multiple ...
2
votes
3answers
409 views
Microsoft's coding standards for ASP.NET controls
I cannot find any naming standards/conventions in MSDN for naming ASP.NET controls.
One of the following standards tends to be used by programmers:
lblAddress
AddressLabel
Address
According to ...
6
votes
3answers
479 views
Programming standards and principles to become better programmer [closed]
I am a c# developer.
I have always been interested in increasing my skills and knowledge and trying to pickup new technology.
However now I want to enhance my knowledge in Programming standards and ...
9
votes
4answers
672 views
C# return variables
In a debate regarding return variables, some members of the team prefer a method to return the result directly to the caller, whereas others prefer to declare a return variable that is then returned ...
7
votes
7answers
973 views
Prevent developers from using constants
I have one one software system which allows developers to specify an ID or name to create NodeReferences. Both work fine, but ID's are not guaranteed to be the same across different environments. I've ...
1
vote
2answers
317 views
coding style for If condition [duplicate]
I came across below style of writing if statements in C#, on msdn code examples. Usually when I write if statements, the conditions I would write `(Customer != null)
I want to know if there is any ...
10
votes
4answers
434 views
Always pull out common cases and branch separately? [duplicate]
We had a disagreement in a code review.
What I had written:
if(unimportantThing().isGood && previouslyCalculatedIndex != -1)
{
//Stuff
}
if(otherThing().isBad && ...
2
votes
2answers
153 views
Style for creating IEnumerable unions
There isn't any cool LINQ sugar for creating unions. The Enumerable.Union() method is usually called like this:
var bigList = list1.Union(list2);
The alternative is to call Enumerable.Union() which ...
3
votes
5answers
207 views
Using 'new' in a projection?
I wish to project a collection from one type (Something) to another type (SomethingElse). Yes, this is a very open-eneded question, but which of the two options below do you prefer?
Creating a new ...
4
votes
4answers
420 views
Switch or a Dictionary when assigning to new object
Recently, I've come to prefer mapping 1-1 relationships using Dictionaries instead of Switch statements. I find it to be a little faster to write and easier to mentally process. Unfortunately, when ...
3
votes
6answers
821 views
Using prefix incremented loops in C#
Back when I started programming in college, a friend encouraged me to use the prefix incrementation operator ++i instead of the postfix i++, citing that there was a slight chance of better performance ...
10
votes
9answers
992 views
LINQ Style preference [closed]
I have come to use LINQ in my every day programming a lot. In fact, I rarely, if ever, use an explicit loop. I have, however, found that I don't use the SQL like syntax anymore. I just use the ...
4
votes
3answers
284 views
Should I prefer properties with or without private fields?
The codebase I'm working in now has the convention of using private fields and public properties. For example, most classes have their members defined like this:
// Fields
private double _foo;
...
0
votes
7answers
2k views
If condition not true: default value or else clause? [closed]
I have searched Programmers and Stackoverflow and was not able to come up with a satisfying answer, even though I'm quite sure it must have been asked many times before. The only question I found has ...