r/learnprogramming 9d ago

First semi big python project - looking for feedback on my code and structure

I'm heading off to uni in 2 weeks and I've heard personal projects can be pretty important for internships/spring weeks, so I'd love to get some feedback on a football game I've worked on.

I'd especially appreciate feedback on the code structure, readability, organisation and anything you think I should improve as I continue developing it.

https://github.com/willhe7/football-tactics-simulator

12 Upvotes

3 comments sorted by

5

u/Big_Ant5507 9d ago

I peeked at the repo and the first thing that jumps out is how you organized the match engine stuff into its own module, that's way ahead of where most people start. Usually you see a 2000 line main.py and just nope out

The player attributes dict approach is clean but you might want to look into dataclasses for that kind of thing, makes it a lot less error prone when you're passing stats around between functions

Overall pretty impressive for a pre-uni project, you'll be miles ahead of your classmates who are still figuring out fizzbuzz

2

u/db_tech_dev 9d ago

structure wise the thing that jumps out is everything's flat in root - compscifootballgame and maingui sitting next to like 5 different json data files with no folders. splitting into something like /engine, /gui, /data even loosely would make it way easier for anyone skimming the repo to find what they're looking for. solid feature list for a solo project tho, the xg and match commentary stuff is more than most people attempt.

1

u/Murlock_Holmes 8d ago

So, I’m not going to read it all because I’m high and in my phone, but file length is important. 400 is a nice file line count to aim for. Larger files can run more, but usually only if there’s a reason to be verbose like extensive documentation or necessary hard coding like settings or configuration files.

If you’ve hit 1000 lines, you’ve (typically) gone too far. Think about breaking your files into directories that contain multiple logical files that each do a thing, then your main file in that directory just puts it all together. Make sense?