Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants