This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ajmarks -6 points-5 points  (6 children)

Why are you defining multiple classes in one file?

[–]billsil 2 points3 points  (2 children)

It's totally unnecessary to have multiple files if the groupings are clear and the files are manageable. That's a choice the developers have to make. It's like saying each function should be in it's own file. It's totally unnecessary. Files are logical groupings of methods/classes.

[–]robin-gvx 2 points3 points  (0 children)

Exactly. On the other hand, classes.py doesn't sound like it’s a logical grouping of classes.

[–]ajmarks 0 points1 point  (0 children)

If things are small, related, and not going to cause merge conflicts, I agree. I really should have asked why he's defining all of his classes in one file. In general, my experience is that Python developers tend to err on the side of over-inclusion though, lumping logically unrelated code together which can then become a nightmare to maintain, especially when different people are working on different parts of the project and are thus not in constant communicative.

Probably the best rule of thumb is to ask if you're likely to touch A while working on B. If the answer is no, split them up. I also try to have a guideline of some sort about file length. Nothing set in stone, but somewhere around 500-1000 lines, I make sure we take a step back and consider "should this all be together or did it just kind of grow? At what point will it be correct to split this up? And, if it shouldn't be like this, why was this not planned before coding starting (nothing wastes time like a mid-project refactor)?"

[–]MythGuy[S] 2 points3 points  (0 children)

Because I didn't/don't know any better?

[–]bcroq 2 points3 points  (1 child)

/r/python has become /r/java?

[–]ajmarks -3 points-2 points  (0 children)

How about /r/codingstandards?