In my work we have a very chaotic django code base that's hard to understand. Any tips on how to learn the code base?
For further actions, you may consider blocking this person and/or reporting abuse
In my work we have a very chaotic django code base that's hard to understand. Any tips on how to learn the code base?
For further actions, you may consider blocking this person and/or reporting abuse
Sukhpinder Singh -
Best Codes -
Ezpie -
Pratik Tamhane -
Top comments (2)
Take notes, create your own map of the project. You can do it by hand or possibly use some software to show the dependency graph. By leveraging visualizations of which files import other files you will see some files/classes stand out in importance.
Make sure your Python fundamentals are strong. If there is unfamiliar syntax then look it up. If the classes use complicated inheritance schemes then try drawing a UML diagram of the classes to help make sense of the relationships.
Look at the tests if they exist. The test cases should help explain what the code does.
If you're lucky enough there might be MyPy type annotations. You can read these and think about the range of all possible values that satisfied those types. If the project doesn't have them, consider learning about types and adding the annotations yourself.
There used to be a package for Django that would visualize the database tables and their relations using the Django models. Try to use that to understand the database. Really focus on the models anyway they are usually the center of a Django code base anyway.
When you are writing notes try not to get bogged down in describing what the code does, but rather to try to figure out what is the intention behind the code. What is the code for? Why does it do things the way that it does? What are the constraints on the system?
All excellent advice! I would add a couple more:
If you aren't sure why a module / file exists, try removing it and seeing what fails (on your own dev box of course, not prod!) This can be especiialy informative if there are end-to-end tests you can run.
Play the hacker - fuzz the app, think about how to break in and get to the data.. you will be more focused on flows through the codebase that touch important things. Make it fun... 😁