Refactoring is the process of taking something and modifying it while maintaining the same functionality. This means any [[Tests]] should still pass. Generally, you take bloated code that has [[Code Smells]] and Coupling and refactor. Just because the logical steps must remain the same, doesn't mean you can't change the physical shape of the code. An extreme example is an entirely hand-coded, 1000 line function can be split up into sub-functions of some of that code was repeated. The shape of the code changed, but the logical steps did not. The first step in any refactoring is to graph or write down all logic flows through the module that's being refactored. Wether that's breaking down use cases, or breaking a function into steps, this info is needed to refactor effectively. ## Terms ### Coupling Coupling is when two pieces of code are dependent on each-other tightly. The strongest form of coupling could be two functions, where one calls the other by name. # References * https://refactoring.guru