I just joined a group of five developers (non-professionals) working on a medium sized Python framework (> 50 modules, > 10.000 lines of code). The project has no documentation whatsoever and there are no coding conventions of any kind. My job is to
- get an overview of what the framework does (theoretical physics calculations),
- write a detailed documentation for the current code,
- define development guidelines,
- design a new software architecture,
- perform code refactoring.
Unfortunately, I'm not used to programming languages with a dynamic type system in such large projects (until now I've used Java for such purposes and Python for shorter scripts).
Speaking in terms of anti-patterns, the code is pure spaghetti code, contains a god class and lots of copy-and-paste programming. In my oppinion, the code has degenerated to a point that is unmaintainable. However, rewriting the entire code is not an option.
In "AntiPatterns: Refactoring Software, Architecture, and Projects in Crisis" William Brown et al. suggest the following steps for code refactoring, when adding new code in such software projects:
- Control access to member variables (in Python I would use properties).
- Avoid duplicated code.
- Reorder function arguments to improve consistency.
- Remove code that is, or may become, inaccessible.
- Rename classes, functions, data types to improve consistency and set standards.
Step 1 seems to be somehow un-Pythonic to me and steps 2-5 are trivial. I have resigned at trying to figure out the big picture. Instead, I am approaching the issues one at a time. However, I am constantly stuck at trying to resolve the insane amount of object coupling.
I am uncertain if my approach is a good idea at all, as I have no experience in software restructuring. It is also hard to ask a specific question as I am stuck in the beginning of my work. I would appreciate if someone could provide insight into best practices in this topic.
Edit: This question now focuses on the approach of restructuring Python frameworks instead of simply getting an overview.