Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

One file per class #2

Open
bhardin opened this issue Dec 21, 2017 · 2 comments
Open

One file per class #2

bhardin opened this issue Dec 21, 2017 · 2 comments

Comments

@bhardin
Copy link
Contributor

bhardin commented Dec 21, 2017

Discussion on best practice of One file per class.

@adambom
Copy link

adambom commented Apr 17, 2018

Inside of the file /apps/vehicles/models.py there is a Car class. The tests for this class are easily found in the file: /apps/vehicles/models/test_car.py

I think this is confusing because you break parity between the source code file hierarchy and the test directories. I like being able to look at a file (and without opening it) know where to find the tests. It just so happens that I'm not particularly fond of defining multiple classes in a single file either. Thus, I propose the following structure:

In source code:
eshares/models/car.py
eshares/models/__init__.py

(instead of eshares/models.py with countless classes embedded in one confusing megafile)

In test code:
test/models/test_car.py

@bhardin
Copy link
Contributor Author

bhardin commented Apr 21, 2018

@adambom Agreed. I also don't like multiple classes per file and think the bloat in models.py is an anti-pattern. Unfortunately, we inherited the bloat in these files and needed a way to bridge our testing until we have good file/class parity.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants