Maximum number of rows recommended

3

Is there a PEP or good practice suggestion that defines what the recommended maximum number of rows a module should be? In my case for example, I keep more than one class per module, obviously classes that are within the same context, domains classes eg. However, I have a module that is already exceeding 450 lines, and I do not know if it would be time to separate. In other languages like Java and C #, a single class per file is usually kept, but in Python it is common to have more than one where the files are called modules.

    
asked by anonymous 21.06.2018 / 21:23

1 answer

2

PEP8 is the most commonly used and well-accepted guide to good practice within python, in it you find several 'conventions' for writing your code.

Splitting your module into smaller modules may also vary according to the purpose you are programming for. If it is a desktop application it may be more advantageous to have more robust blocks, otherwise, web applications tend to have the code better divided. I quote here a passage from the book Thoo scoops of Django , which brings together conventions and tips useful for organizing your project:

  

When in doubt, keep the apps small.

While the book is geared towards web development, I personally always try to keep that perspective in mind, but it is worth taking into account the semantic factor of the code, as Anderson said previously.
It makes sense that all that your block of code is together in one place, and you think that breaking it into smaller fragments would only make it difficult to read it, there is no reason why it. Home PEP8 is there to assist you, but your doubt, as you can see, seems to be somewhat subjective. I leave some reading recommendations that I hope will help you. If you are a solo programmer try to read the PEP and find the one that suits you best, if you program with a team, try to talk to the other programmers and find a form that is intelligible to everyone.

Complement Read

22.06.2018 / 00:24