Top "Refactoring" questions

Refactoring is a disciplined technique for restructuring existing code, altering its internal structure without changing its external behavior.

Refactoring a static class to use with dependency injection

We need to use an unmanaged library in our code that has static methods. I'd like to introduce the library …

c# dependency-injection refactoring singleton static-classes
Find unused code in a Rails app

How do I find what code is and isn't being run in production ? The app is well-tested, but there's a …

ruby-on-rails ruby refactoring code-coverage
Refactoring if-else if - else

I have the following code example if(object.Time > 0 && <= 499) { rate = .75m } else if(object.Time >= 500 &…

c# design-patterns if-statement refactoring solid-principles
Cognitive Complexity and its effect on the code

W.r.t to one of the java projects, we recently started using SonarLint. Output of the code analysis shows …

java algorithm mapreduce refactoring sonarlint
Ways to ASSERT expressions at build time in C

I'm tidying up some older code that uses 'magic numbers' all over the place to set hardware registers, and I …

c refactoring assert static-assert
How should I rewrite a very large compound if statement in C#?

In my C# code, I have an if statement that started innocently enough: if((something == -1) && (somethingelse == -1) &…

c# refactoring structure if-statement guard-clause
Reusing MyBatis ResultMap in multiple mapper.xml

I would like to re-use a specific from different *Mapper.xml files which all somehow read same objects. I have …

refactoring mybatis resultset mappers
How do you refactor a God class?

Does anyone know the best way to refactor a God-object? Its not as simple as breaking it into a number …

class refactoring anti-patterns god-object
Ruby way: catch division by zero

I have the following method to compute an average: def compute_average(a,b,c,d,e) total = [a,b,…

ruby refactoring divide-by-zero
How can you find unused functions in Python code?

So you've got some legacy code lying around in a fairly hefty project. How can you find and delete dead …

python refactoring dead-code