3 ms·
To add to the sibling comments, nudging you into module level constructors for classes will encourage more modularity in general. If you have a class like thi
by gorgoiler 4y ago
To add to the sibling comments, nudging you into module level constructors for classes will encourage more
modularity in general.
If you have a class like this with a separate constructor in the same scope as the class…
class Cow:
def __init__(self, name)
…
def random_cow() -> Cow:
return Cow(uuid())
…you are more likely to roll this all up into farm.cow than you are to lump all the animals together in a single farm module.
Modularity is nice of course because it helps you step away from implementation detail (close the file, forget about how it works, and just use it) and your code gets split up into little pieces that helps your e.g. bazel monorepo build/test work efficiently.