Questions tagged [refactoring]
Refactoring is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior.
756 questions
2 votes
2 answers
304 views
How to design extensible data aggregation code to avoid manual updates in multiple places?
I have a data aggregation function that collects statistics from multiple sources. The problem is that whenever I add a new metric, I need to manually update the code in three different places, which ...
18 votes
7 answers
4k views
Is there a reason "replace conditional with table" isn't a standard refactoring?
I'm preparing a lecture where I will start with a many-branched conditional statement and replace it with a table. For example, I could start with: function getMonthName(monthNumber) { if (...
2 votes
2 answers
2k views
Refactoring a legacy codebase with a god Repository and incomplete Clean Architecture [duplicate]
I'm currently working on a large legacy project that tried to implement Clean Architecture combined with MVVM, but unfortunately didn't fully adhere to the principles. One major problem: The ...
4 votes
1 answer
297 views
Refactoring a codebase from manual memory management to RAII
Edit: @Ben Cottrell's comment said this was similar to a question about spaghetti code. While both questions involve large codebases, mine addresses a specific technical pattern: manual memory ...
3 votes
5 answers
1k views
What is the root cause of a proliferation of "null checks"?
I work with a lot of Groovy code. One feature of the language is the "safe navigation operator" (?), which I think of as an inline null check. There are many things about Groovy that I like, ...
0 votes
4 answers
291 views
Refactoring the application with correct SemVer approach
Suppose I have an application with version 1.2.3. If I refactor my application to remove deprecated calls while maintaining the same functionality and API as in version 1.2.3, what version number ...
2 votes
3 answers
241 views
Is it still "feature envy" if the state to make decision or the action to take after asking the state involves other classes to participate?
According to https://softwareengineering.stackexchange.com/a/212130/432039, if a class asks another class for the state, and then call methods of that class, it is called "feature envy", eg: ...
0 votes
1 answer
230 views
Our php codes base has 6 different ways to do INSERT … ON DUPLICATE KEY UPDATE, how do I fix it?
Our php codes base has 6 different ways to do INSERT … ON DUPLICATE KEY UPDATE. It happened over years because the php framework is evolving and my team members come and go, although I won't say we ...