Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to properly organize a package/module dependency tree?
    primarykey
    data
    text
    <p>Good morning,</p> <p>I am currently writing a python library. At the moment, modules and classes are deployed in an unorganized way, with no reasoned design. As I approach a more official release, I would like to reorganize classes and modules so that they have a better overall design. I drew a diagram of the import dependencies, and I was planning to aggregate classes by layer level. Also, I was considering some modification to the classes so to reduce these dependencies.</p> <p>What is your strategy for a good overall design of a potentially complex and in-the-making python library? Do you have interesting suggestions ?</p> <p>Thanks</p> <p><b>Update:</b></p> <p>I was indeed looking for a rule of thumb. For example, suppose this case happens (<strong>init</strong>.py removed for clarity)</p> <pre><code>foo/bar/a.py foo/bar/b.py foo/hello/c.py foo/hello/d.py </code></pre> <p>now, if you happen to have d.py importing bar.b and a.py importing hello.c, I would consider this a bad setting. Another case would be</p> <pre><code>foo/bar/a.py foo/bar/baz/b.py foo/bar/baz/c.py </code></pre> <p>suppose that both a.py and b.py import c. you have three solutions: 1) b imports c, a import baz.c 2) you move c in foo/bar. a.py imports c, b.py imports .c 3) you move c somewhere else (say foo/cpackage/c.py) and then both a and b import cpackage.c</p> <p>I tend to prefer 3), but if c.py has no meaning as a standalone module, for example because you want to keep it "private" into the bar package, I would preferentially go for 1).</p> <p>There are many other similar cases. My rule of thumb is to reduce the number of dependencies and crossings at a minimum, so to prevent a highly branched, highly interweaved setup, but I could be wrong. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload