Tools and practices to help you deal with legacy code - Dennis Doomen - NDC Porto 2023
Interesting. speech To work with the legacy of the past, or more simply. Get in the code. In this talk, the author cites an algorithm of his actions as a consultant who is called to study archaeology around legacy systems. The algorithm seemed interesting to me, so I decided to write it down briefly. Dennis begins with a sales analysis, including a study of running processes and their configuration. Next, he studies the code and its structure and looks for problems - usually these are the problems that get in the way of the client and he urges Dennis to solve them. Dennis compares the code to the version control system and looks for commented or modified parts of the code. It examines log files, as well as crash reports and problems already found. Next, Denis is engaged in exploratory testing and tries to reproduce the problems reported by customers. When studying the code, the author pays attention to namespaces, approaches to class and function naming, and also creates mental maps and visualizes the dependencies between the parts of the project. The author notes that now there are AI tools that can be asked to explain the logic of a piece of code. To improve the code base, it is worth removing pieces of unused code - if they are found, then we can restore them from the version control system. Before making changes to the code, the author creates safety nets, creating high-level tests that allow you to track changes in the behavior of the program. Working Effectively with Legacy Code by Michael Feathers Next, the author works on automating the assembly and deployment of the program, so as not to do it with your hands, but to make a normal CI / CD pipeline. The author recommends Ansible or Pulumi
- Separately, the author talks about the strategy of branching and versioning of the program (semver) You also need to build work with exceptions, do normal logging with levels and use open telemetry for traying. The next step is to use a static code analyzer, in .net the author recommends Roslyn Next, the author format the code into a single style and apply this change with one commit, and then configure the linters and maintain this style:) The author is drowning for even using new language capabilities on old platforms, using the analog polyfills from js, but for .net platforms. Next, the author talks about the restructuring of the code and the transfer of connected parts to separate functional folders, separately he proposes to duplicate the code to reduce coupling of different parts of the code. (It allows you to leave fewer connections, although for the sake of duplication.) An important part is devoted to the application of design patterns in refactoring old code - the author considers them useful idioms that reduce the complexity of old code by using familiar concepts. Next, the author recalls SOLID and separately mentions the latest concept with DIP. (dependency inversion principle), which helps us organize dependencies between parts of our legacy application. The author says that dependence should be left on more abstract and stable components and if you want to allocate dependence in the interface and use inversion. The author recalls composition and inheritance and explains why he prefers the former to the latter. And the end of the speech is devoted to architecture, where the author recalls onion architecture, hexagonal architecture, clean architecture and says that they solve certain classes of problems:) So we have to choose architecture from what problems we want to solve.
In the end, the author has a good story about what you need to do to your legacy. (legacy app) It was shining with new colors.)
#Software #Architecture #SoftwareDevelopment