Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Coding practice, project folder structure

I'm currently making a simple manager game/simulation to learn how to handle bigger projects. As it is now, I have all my classes just in the /src folder created by Eclipse.

I feel that it would be a good idea to structure my project. I have the following classes:

  • Match
  • TeamMatch
  • Player
  • PlayerFactory
  • Team
  • TeamFactory
  • TeamSchedule
  • Season

Now, one idea(and probably the right thing to do anyway!) would be to create Interface for matches, and have both Match and TeamMatch implement it. I think the logical follow up would be to have a folder named after the interface, and have the related classes inside.

But what about Player and PlayerFactory classes? Player has the basic info of a player, like age, name, etc. PlayerFactory creates Players as requested. But finding a common interface for these classes doesn't seem likely! Same with TeamFactory. Maybe have all the factory classes grouped together?

Let's look at the Team class. A team consists of players. Should these two be grouped together? A season has TeamSchedule, which has TeamMatches inside, which in turn has two teams.

This is one option I'm thinking about:

  • src
    • match
      • Match
      • TeamMatch
    • factories
      • PlayerFactory
      • TeamFactory
    • league
      • Season
      • Player
      • Team
      • TeamSchedule

Any suggestions, blatant mistakes I've made or completely different views on the subject?

like image 735
Zavior Avatar asked Dec 06 '25 03:12

Zavior


1 Answers

I would suggest:

create a base package which should have a name like org.managergame.

create three packages under the base package named team, match, player.

Match and TeamMatch go to the package match.

Player and PlayerFactory go to the package player.

Team, TeamFactory and TeamSchedule go to the package team.

Everything else can be under the base package.

like image 52
belgther Avatar answered Dec 08 '25 15:12

belgther