There is an unwritten law in software development and IT operations. An anti-pattern1 for effective problem solving and complexity reduction. No one is crazy enough to adopt it. No customer on earth willing to pay for it. But they exist, the bright moments in the life cycle of a company, where this law can be applied. Here’s how it can be defined:
If you have a task or problem and you know how to solve it, then throw away your code after completion and tear apart an installation again.
Repeat everything, but document every step in the second attempt. When finished, throw everything away one more time and continue to work only with the documentation. Think about simplifications, vary the procedures, create recursions, whatever, but always strive to reduce complexity without succumbing to the temptation to add functionality2.
Once the documentation is in place, the final attempt can be made to solve the problem. You will see that while the first attempt took weeks and the second days, the third will be easily done and can be measured in hours. Simultaneously, the final solution is sustainable, usually elegant, and free of ballast, complexity and any design flaws. And by the way: this is exactly the hallmark of good documentation.
Wish you good luck,