📜 ⬆️ ⬇️

Practice refactoring in large projects

Some time ago I got into game dev, where I ran into projects of 2 million lines of code written by dozens of programmers. At such a scale of the code base, problems of a previously unknown nature arise. I want to tell you about one of them now.

So imagine the following situation. It just so happens that you need to refactor a very large piece of code, the whole subsystem. Rows, commercials, at 200K. Moreover, refactoring clearly looks very large, affecting the basic concepts by which your subsystem is built. In fact, it is necessary to rewrite the entire architecture, preserving the business logic. This happens if, for example, you have done one project and you have a new one ahead, and you want to correct all the mistakes of the past in it. Suppose, according to first estimates, it is necessary to refactor month 2, no less. In the process of refactoring, everything should work, including not to prevent other programmers from adding new features and fixing bugs in the subsystem. Often, such refactoring is how complicated, that it is absolutely impossible to freeze the old code into a new one, and also it is impossible to roll out the result in parts. In fact, you need to replace the engine of the aircraft on the fly.

Examples from the practice, both mine and my colleagues:

')
What to do? Which way to approach the problem? Below is a set of tips and practices that help us deal with this problem. First, more general words, and then specific techniques. In general, nothing supernatural, but someone can help.

Preparing for refactoring



Refactoring


Additional tips



Experience suggests that even scary and large subsystems can be refactored with relatively little blood. Your main assistants are tests and systematic.

Source: https://habr.com/ru/post/150027/


All Articles