Tagged Questions
36
votes
14answers
2k views
Should I encourage junior developers to use explicit or implicit typing?
I am looking to solicit the community's opinion on whether or not it would be advisable to teach junior developers to code with implicit typing (using var) or should I encourage the use of explicit ...
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 ...
12
votes
12answers
827 views
What is the regarded current best practises regarding the “this” keyword in front of field and methods in c#?
Unless it is needed to differentiate between a variable and field with the same name, I never put this. in front of a field or any member access in C#. I see this as no different to m_ prefix that ...
12
votes
6answers
610 views
When should I use a 2-property class over a pre-built structure like a KeyValuePair?
When should you put Key/Value type of data in it's own class instead of using a pre-built generic structure, such as a KeyValuePair or a Tuple?
For example, most ComboBoxes I create contain a ...
10
votes
9answers
1k 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 ...
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 && ...
10
votes
5answers
1k views
Why have a method that returns a bool/int and has the actual object as an output parameter?
I see the following code pattern all over the place in my company's codebase (.NET 3.5 application):
bool Foo(int barID, out Baz bazObject) {
try {
// do stuff
bazObject ...
9
votes
4answers
674 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 ...
8
votes
3answers
2k views
What should I include in XML documentation comments?
I'm trying to make a point of documenting my code better, especially when it comes to the XML comments on class members, but often it just feels silly.
In the case of event handlers, the naming ...
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 ...
7
votes
4answers
323 views
Warn about 3rd party methods that are forbidden
Note: This question refers to code written in Java or C#.
I am managing a couple of large projects where we have discovered issues (not necessarily bugs) with some 3rd party/SDK methods and have ...
6
votes
2answers
535 views
Is this awkward spacing some type of style?
In reading another programmers code, he uses a format I have never seen. E.G.
namespace MyNs.HereWeAre
{//tab here for some reason
public class SomeClass
...
6
votes
4answers
1k views
Are fluent interfaces more flexible than attributes and why?
In a EF 4.1 Code First tutorial the following code is given:
public class Department
{
public int DepartmentId { get; set; }
[Required]
public string Name { get; set; }
public virtual ...
6
votes
3answers
480 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 ...
5
votes
3answers
455 views
Is it bad idea to use flag variable to search MAX element in array?
Over my programming career I formed a habit to introduce a flag variable that indicates that the first comparison has occured, just like Msft does in its linq Max() extension method implementation
...