Skip to main content

All Questions

118 votes
16 answers
24k views

Should I add redundant code now just in case it may be needed in the future?

Rightly or wrongly, I'm currently of the belief that I should always try to make my code as robust as possible, even if this means adding in redundant code / checks that I know won't be of any use ...
KidCode's user avatar
  • 2,213
88 votes
11 answers
19k views

Is it a bad practice to modify code strictly for testing purposes

I have a debate with a programmer colleague about whether it is a good or bad practice to modify a working piece of code only to make it testable (via unit tests for example). My opinion is that it ...
liortal's user avatar
  • 1,185
56 votes
3 answers
74k views

Which is a better practice - helper methods as instance or static?

This question is subjective but I was just curious how most programmers approach this. The sample below is in pseudo-C# but this should apply to Java, C++, and other OOP languages as well. Anyway, ...
Ilian's user avatar
  • 663
50 votes
5 answers
62k views

When and why to use Nested Classes?

Using Object Oriented Programming we have the power to create a class inside a class (a nested class), but I have never created a nested class in my 4 years of coding experience. What are nested ...
mayur rathi's user avatar
42 votes
8 answers
45k views

Private variable vs property?

When setting a value to a variable inside of a class most of the time we are presented with two options: private string myValue; public string MyValue { get { return myValue; } set { myValue = ...
Edward's user avatar
  • 2,179
40 votes
6 answers
38k views

Try/Catch/Log/Rethrow - Is Anti Pattern?

I can see several post where importance of handling exception at central location or at process boundary been emphasized as a good practice rather than littering every code block around try/catch. I ...
rahulaga-msft's user avatar
36 votes
5 answers
68k views

Is it a good practice to create a ClassCollection of another Class?

Lets says I have a Carclass: public class Car { public string Engine { get; set; } public string Seat { get; set; } public string Tires { get; set; } } Lets say we're making a system ...
Luis's user avatar
  • 535
30 votes
5 answers
39k views

When and why you should use void (instead of e.g. bool/int)

I occasionally run into methods where a developer chose to return something which isn't critical to the function. I mean, when looking at the code, it apparently works just as nice as a void and after ...
Independent's user avatar
28 votes
15 answers
5k views

Is it wise to be going back and forth between two programming languages? [closed]

I have been writing quite a lot of PHP for nearly two years. Now I am doing .NET (mainly c#) development. However, sometimes I go back and do some php. My main question is, is it wise for me to ...
26 votes
3 answers
17k views

Should I avoid using unsigned int in C#?

I recently thought about the use of unsigned integers in C# (and I guess similar argument can be said about other "high level languages") When In need of an integer I am normally not faced with the ...
Belgi's user avatar
  • 567
22 votes
4 answers
10k views

Is the "Gets or sets .." necessary in XML documentation of properties?

I am looking for a recommendation of a best practice for XML comments in C#. When you create a property, it seems like that the expected XML documentation has the following form: /// <summary> /...
Tomas's user avatar
  • 265
21 votes
9 answers
3k views

How to teach Exception Handling for New Programmers? [closed]

How do you go about teaching Exception Handling to Programmers. All other things are taught easily - Data Structures, ASP.NET, WinForms, WPF, WCF - you name it, everything can be taught easily. With ...
Kanini's user avatar
  • 2,258
15 votes
3 answers
12k views

Child to Parent linking - bad idea?

I have a situation where my parent knows about it's child (duh) but I want the child to be able to reference the parent. The reason for this is that I want the child to have the ability to designate ...
Thraka's user avatar
  • 362
13 votes
2 answers
5k views

What is the best approach for inline code comments?

We are doing some refactoring to a 20 years old legacy codebase, and I'm having a discussion with my colleague about the comments format in the code (plsql, java). There is no a default format for ...
Diego Alvarez's user avatar
12 votes
4 answers
3k views

How do I wrap a service so it is simpler

We have a dependency to a third-party service which exposes a gigantic interface of which we only need like 3 methods. Additionally, the interface changes frequently... I've decided to wrap the ...
xeraphim's user avatar
  • 339

15 30 50 per page
1
2 3 4 5 6