I am about to embark on a personal JAVA project in eclipse where myself and a friend create a game server, game engine, and a game based on an existing card game. The game server will come last, but for now I'd like to concentrate on building the card game engine followed by the game itself.
In school, we would just create packages like gameEngine.whatever
and then the different games would be in packages like game.gameName.whatever
. I was thinking of making the game engine its own separate project and then have the game be an individual project as well, instead of having them all in one project and separating them based on packages, like I've done in school. In my internships, we have multiple projects working together, but have not touched on that in classes at all.
Is there any difference in doing it one way versus the other? Or are they basically equivalent? Thanks!
If I understand your situation correctly, you should not worry too much about code organisation at this point. Of course there are some projects where it is clear upfront as to where what goes in. Not so in many cases.
In your case, as you start implementing things, you'll gain more clarity on the direction to take and the organisation. One advantage of using IDEs like eclipse is that you can refactor code (both packages or even move packages/classes across projects) at a later stage. For eclipse, the code is not just files/directories. It is looking at the parse tree and so can let you move around a lot of fine stuff safely - moving code across packages or projects is among the most trivial things it can do.
Just focus on what you have to do and try to make progress with the real stuff. If you have to worry about multiple projects, you'll know when to. I'd suggest starting off with something like:
Create one project for now. First find a standard and unique package prefix. Say you decided to go with something like "org.abc" (just an example not a good one)
Now start working on your project. As you keep adding classes, focus on organising well just package wise. Keep adding packages as you go. For instance..
org.abc.game.engine
org.abc.game.util
org.abc.game.games.mario
org.abc.game.engine.phy
org.abc.game.server
org.abc.game.common
...
After a while when you want-to, you can create the new projects. For instance you can decide to
call the current project as GameMario
move the entire org.abc.game.common and org.abc.game.util with some files to a project called GameCommon. The same package can exist (and in many cases do) in two projects
move the org.abc.game.engine, org.abc.game.server and all their sub-packages to a new project GameServer and continue adding game server code in that project
Both GameMario and GameServer will have a project dependency on GameCommon
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With