How to deal with constructor over-injection in .NET

You are correct: if you need to inject 13 dependencies into a class, it’s a pretty sure sign that you are violating the Single Responsibility Principle. Switching to Property Injection will not help, as it will not decrease the number of dependencies – it will only imply that those dependencies are optional instead of mandatory. … Read more

Should we compare floating point numbers for equality against a *relative* error?

It all depends on the specific problem domain. Yes, using relative error will be more correct in the general case, but it can be significantly less efficient since it involves an extra floating-point division. If you know the approximate scale of the numbers in your problem, using an absolute error is acceptable. This page outlines … Read more

Fluent Interfaces – Method Chaining

The core idea behind building a fluent interface is one of readability – someone reading the code should be able to understand what is being achieved without having to dig into the implementation to clarify details. In modern OO languages such as C#, VB.NET and Java, method chaining is one way that this is achieved, … Read more

Are exceptions really for exceptional errors? [closed]

This sounds over-simplistic, but I think it makes sense to simply use exceptions where they are appropriate. In languages like Java and Python, exceptions are very common, especially in certain situations. Exceptions are appropriate for the type of error you want to bubble up through a code path and force the developer to explicitly catch. … Read more

Is Sleep() evil?

I actually believe the assertion you linked is correct. The problem is sleep is being used (as you noted) as an inefficient substitute for notification mechanisms. Sleep is always inferior to a properly implemented notification mechanism, If you are waiting for an event. If you actually need to wait a specific amount of time for … Read more

What is an ideal variable naming convention for loop variables? [closed]

I always use a meaningful name unless it’s a single-level loop and the variable has no meaning other than “the number of times I’ve been through this loop”, in which case I use i. When using meaningful names: the code is more understandable to colleagues reading your code, it’s easier to find bugs in the … Read more

Semantic Diff Utilities [closed]

We’ve developed a tool that is able to precisely deal with this scenario. Check http://www.semanticmerge.com It merges (and diffs) based on code structure and not using text-based algorithms, which basically allows you to deal with cases like the following, involving strong refactor. It is also able to render both the differences and the merge conflicts … Read more