Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (579)
games submitted by our members
Games in WIP (500)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Java game project organization  (Read 1262 times)
0 Members and 1 Guest are viewing this topic.
Offline jasox

Senior Newbie





« Posted 2011-10-29 13:13:22 »

What is best practices to organize game in ide. What packages should I have (ui, models ...) ?
Offline Fokusas

Senior Member


Medals: 3
Projects: 1



« Reply #1 - Posted 2011-10-29 15:35:59 »

I think that you should stick to package concept.
You can read more about it there http://download.oracle.com/javase/tutorial/java/package/packages.html
Offline lesto

Senior Newbie





« Reply #2 - Posted 2011-10-29 15:42:51 »

at least a revision sistem, live SVN, GIT or like.
do many branch, and learn haw to use them.

I don't think you need something else, if you are alone or with just 2 or 3 friend.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline sproingie
« Reply #3 - Posted 2011-10-29 17:54:06 »

Organizing packages is a matter of taste.  Sun recommends the reversed DNS model for packages, but I find it's not strictly necessary, and projects like Akka and Play are starting to break with that tradition (they have top-level namespaces of akka.* and play.* respectively).  If you do go that route, you obviously don't want to use a really generic word as your top level package like game.* for instance.  Using your project name is a good idea.

As for organizing sources, I'm a fan of using the maven layout, even if I'm not actually using maven.

A typical maven layout looks like this:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
src/
    main/
        java/
            com/
                foo/
                    Blah.java
        resources/
            images/
                ground.png
    test/
        java/
        resources/


It looks a little deeply nested but any IDE should give you a package view that hides all that.  It makes it easy to support multiple languages (only compiling one language at a time) and easy to find resources like assets and config when they're not mixed into the sources.  Compilation goes to a target/ directory, and the internal organization of that isn't all that important as long as it works and that you're able to blow it away any time you want.

Version control is just plain mandatory.  Not using version control is like never saving your documents.  You should get in the habit of thinking of your filesystem as just a local cache, where you're really saving your files to VC.  As preferred version control goes, I would recommend something decentralized like git or mercurial, but even subversion is better than nothing.
Offline zendar

Senior Newbie




Go Java!


« Reply #4 - Posted 2011-10-29 19:37:43 »

<snip>
As for organizing sources, I'm a fan of using the maven layout, even if I'm not actually using maven.

<snip>

Version control is just plain mandatory.  Not using version control is like never saving your documents.  You should get in the habit of thinking of your filesystem as just a local cache, where you're really saving your files to VC.  As preferred version control goes, I would recommend something decentralized like git or mercurial, but even subversion is better than nothing.



I agree with sproingie. Use version control. Even if you just learn the basic code&commit cycle, it will make you less afraid to try new things, and give you the possibility to revert any bad changes. Not to mention that if you use a free service like bitbucket.org, then you get offsite backup for free.

I would fret too much over package layout. Start with the basic layout that sproingie suggested, and put stuff where it seems sensible at the time. If you are using any modern IDE, then you will have built in refactoring tools that will make moving classes to different packages very easy.

Good luck  Cool
Offline Orangy Tang

JGO Kernel


Medals: 51
Projects: 11


Monkey for a head


« Reply #5 - Posted 2011-10-29 20:48:57 »

Organizing packages is a matter of taste.  Sun recommends the reversed DNS model for packages, but I find it's not strictly necessary, and projects like Akka and Play are starting to break with that tradition (they have top-level namespaces of akka.* and play.* respectively).  
I think if you're writing a public API then reversed dns naming for packages should be mandatory IMHO. Otherwise you risk namespace collisions and that's never fun. But if it's just for your own use then it's not a problem - all my actual game code tends to go under gamename.* for instance.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline sproingie
« Reply #6 - Posted 2011-10-30 01:02:57 »

You can in theory incur namespace collisions, but the likelihood of anything using akka also importing another library calling itself akka with overlapping class names is too low to even think about.  But yes, if every library took a top level namespace name, the odds of a namespace collision go up, and you'd have to hack on the library source to fix it.  Java really needs a built-in module system to address this (and a lot of other shortcomings of packages), and that might be a possibility in Java 8.  OSGi fixes this right now, but it's kind of complicated to say the least.  

One thing I've seen a lot lately is to use the name of the project hosting site, like "com.github.foobar" for the "foobar" project on github.  This can suck if you switch hosting sites, but it's still a good interim name if you're not sure what else to use.
Offline jasox

Senior Newbie





« Reply #7 - Posted 2011-10-30 13:47:34 »

Tnx guys.
Offline Orangy Tang

JGO Kernel


Medals: 51
Projects: 11


Monkey for a head


« Reply #8 - Posted 2011-10-30 13:52:20 »

But yes, if every library took a top level namespace name, the odds of a namespace collision go up, and you'd have to hack on the library source to fix it.  Java really needs a built-in module system to address this

This is silly. Java *already* has a mechanism to address this, and it's the aforementioned reverse-domain naming convention.

The problem is arrogant devs who think that somehow their library is exempt from the naming rules.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline jasox

Senior Newbie





« Reply #9 - Posted 2011-10-30 18:51:33 »

But yes, if every library took a top level namespace name, the odds of a namespace collision go up, and you'd have to hack on the library source to fix it.  Java really needs a built-in module system to address this

This is silly. Java *already* has a mechanism to address this, and it's the aforementioned reverse-domain naming convention.

The problem is arrogant devs who think that somehow their library is exempt from the naming rules.

I started new little game and this is how I organized it
--src
--------ba.jaso.logic

--------ba.jaso.modules

--------ba.jaso.ui

--------ba.jaso.resources
.
.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (33 views)
2014-04-15 18:08:23

BurntPizza (30 views)
2014-04-15 03:46:01

UprightPath (45 views)
2014-04-14 17:39:50

UprightPath (28 views)
2014-04-14 17:35:47

Porlus (45 views)
2014-04-14 15:48:38

tom_mai78101 (66 views)
2014-04-10 04:04:31

BurntPizza (126 views)
2014-04-08 23:06:04

tom_mai78101 (226 views)
2014-04-05 13:34:39

trollwarrior1 (191 views)
2014-04-04 12:06:45

CJLetsGame (199 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!