Skip to main content

Questions tagged [refactoring]

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

Filter by
Sorted by
Tagged with
2 votes
2 answers
304 views

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 ...
Tank's user avatar
  • 37
18 votes
7 answers
4k views

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 (...
Ellen Spertus's user avatar
2 votes
2 answers
2k views

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 ...
developKinberg's user avatar
4 votes
1 answer
297 views

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 ...
Arno's user avatar
  • 151
3 votes
5 answers
1k views

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, ...
Gus Murphy's user avatar
0 votes
4 answers
291 views

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 ...
Rafael's user avatar
  • 19
2 votes
3 answers
241 views

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: ...
wcminipgasker2023's user avatar
0 votes
1 answer
230 views

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 ...
Qiulang 邱朗's user avatar
4 votes
5 answers
414 views

A follow up question to How do unit tests facilitate refactoring without introducing regressions?. I said that integration tests test the behavior of the code, while unit tests, being tied to ...
gaazkam's user avatar
  • 4,529
0 votes
2 answers
391 views

there is an app with lets say, 75 years worth of development in it. The frontend is a bit a chaos, there is jquery, there is vuejs (vue 2 of course), there is a lot of server side rendering with over ...
Toskan's user avatar
  • 280
0 votes
1 answer
140 views

I need some guidance on how to send error responses to client from WebAPI controller for an update operation. I need to check if data is changed and if it has duplicate data. I have service class that ...
Sunny's user avatar
  • 945
1 vote
1 answer
176 views

We are finishing up a long (over 1 year) project to retire our monolith. We have been moving pieces of functionality into microservices guided by domain driven design. So far we have been leaving the ...
sceaj's user avatar
  • 324
5 votes
2 answers
2k views

Recently I've come to discover that I've inherited one of the internal auxilliary programs used. I've made a few minor fixes and features to improve it in the past, but now I've been given a major ...
rdi_pck's user avatar
  • 61
0 votes
0 answers
62 views

I am trying to write a simulation that has multiple (20+) variables, which the user should be able to control without modifying the source code. Currently I'm stuck between two design choices: Should ...
z.x.99's user avatar
  • 101
1 vote
3 answers
223 views

I recently finished an interview with a company as a web developer. I'm the first and only developer that is about to be hired in this company. They have a web application that was created by a ...
Saud Alghamdi's user avatar
3 votes
2 answers
485 views

This well-known article criticises Java on the basis that it does not allow you to write functions that do not live in a class. This flaw forces you to write classes with names that look suspiciously ...
J. Mini's user avatar
  • 1,015
0 votes
2 answers
383 views

I have recently encountered this problematic method (minimal reproducible sample in C++ but this question aims to be language agnostic past the syntax): void MyObject::twice_bind_cycle() { _bind1()...
goober's user avatar
  • 117
1 vote
2 answers
195 views

What is a good pattern to refactor a chunk of code where you can identify smaller chunks, but the results of these smaller chunks are used in other chunks? An example should make things more clear. ...
Peter's user avatar
  • 988
13 votes
4 answers
2k views

When in the refactoring step of a TDD process, if we "factor out" some common functionality from two (or more) code modules, how do we avoid that "factored out" code not being ...
Rob Gilton's user avatar
0 votes
2 answers
277 views

I have a colleague that insists refactoring to make the code testable and introduce tests should be independent from changes in architecture as part of refactoring, e.g. introducing a factory pattern. ...
DaveO's user avatar
  • 136
0 votes
3 answers
785 views

I know there are potential duplicates, but imo this is different because there are around 100 developers actively working on this nightmare. I have unfortunately gotten into a job where this GUI ...
hyperbole's user avatar
-2 votes
1 answer
407 views

I work on WPF applications used in testing hardware. I need to make my code base more testable and re-usable. I believe DI would help, but I'm not quite sure where to start. I've done my best with the ...
Dink McDinkleman's user avatar
0 votes
1 answer
1k views

I'm learning how to write unit tests on a project I'm doing with my friends. One thing we tried was to mock the return values of function calls if the functions are declared in a different "...
learningtech's user avatar
1 vote
0 answers
238 views

For a middleware solution I expose an API, which processes data and sends the necessary information to different parties. In the current design we create a new client, which acts sort of like an ...
M. Mayhem's user avatar
2 votes
2 answers
487 views

I'm working with a legacy codebase that has a lot of functions with a nullcheck on the same object. Example: std::vector<SessionNode*> * SessionManager::SessionMap; Session * getSession(int ...
Siddiqui's user avatar

1
2 3 4 5
16