How can I use Python for large scale development?

后端 未结 8 1187
梦谈多话
梦谈多话 2021-01-29 21:33

I would be interested to learn about large scale development in Python and especially in how do you maintain a large code base?

  • When you make incompatibility ch

8条回答
  •  失恋的感觉
    2021-01-29 22:06

    Here are some items that have helped me maintain a fairly large system in python.

    • Structure your code in layers. i.e separate biz logic, presentation logic and your persistence layers. Invest a bit of time in defining these layers and make sure everyone on the project is brought in. For large systems creating a framework that forces you into a certain way of development can be key as well.

    • Tests are key, without unit tests you will likely end up with an unmanagable code base several times quicker than with other languages. Keep in mind that unit tests are often not sufficient, make sure to have several integration/acceptance tests you can run quickly after any major change.

    • Use Fail Fast principle. Add assertions for cases you feel your code maybe vulnerable.

    • Have standard logging/error handling that will help you quickly navigate to the issue

    • Use an IDE( pyDev works for me) that provides type ahead, pyLint/Checker integration to help you detect common typos right away and promote some coding standards

    • Carefull about your imports, never do from x import * or do relative imports without use of .

    • Do refactor, a search/replace tool with regular expressions is often all you need to do move methods/class type refactoring.

提交回复
热议问题