2

I apologize if this has been asked before, but I believe that for me, this question falls under the "I have no idea what I should even google" category.

So, as a noobie to the coding world, I have only recently begun delving into projects that encompass more than a few source files. I am beginning my first "big" project, and before I begin, I would like to know the best way to go about managing many different pieces of a system.

For example: I have Project0 which is built from the pieces A through Z. Each piece is comprised of 50 separate source files, src0 through src50. What is the proper folder structure for this set up? Also, is this a perfect use for Java's package structure?

Kai
  • 38,985
  • 14
  • 88
  • 103
mmmeff
  • 1,025
  • 9
  • 20
  • How to organize projects is arbitrary, but should be consistent. Yes, this is what packages are for. What to put into which package is where things get interesting, and there's more than one way to organize any project. – Dave Newton Dec 27 '11 at 03:28

1 Answers1

2

Names like "A" to "Z" do not convey much meaning. It's the same for "src0" to "src50".

But if that's really what you want, in a typical Java project it may look like this:

.../Project0/
       |
       +----/src/com/meff/a/
       |              |
       |              +-Src0.java
       |              +-Src1.java
       |              .
       |              .
       |              .
       |              +-Src50.java
       |
       +----/src/com/meff/b/
                      +-Src0.java
                      +-Src1.java
                      .
                      .
                      .
                      +-Src50.java 

Once again, such a naming scheme would be absolutely terrible. I just put it there because that's the example you used and it may help you organize your first project...

So you should use directories to represent your packages (and by conventions they should be in lowercase). Your "pieces" "A" through "Z" [sic] becomes "package" "a" through "z".

Then your source code files become Java classes (and by conventions they should be starting with an uppercase).

It's also convenient to use a domain name you own as part of your hierarchy (I know you don't own "meff.com", but you get the idea).

So your "src0" from your "piece A" [sic] becomes a Src0.java file located in .../Project0/src/com/meff/a/ and looks like this:

package com.meff.a;

public class Src0 {
   ...
}

Note that it's typical to have a src/ directory. If you're adding unit tests to your projects, for example, you may also to add a test directory at the same level as the src/ directory, etc.

Hope it helps and change your "A to Z" and "src0 to src50" to something meaningful : )

TacticalCoder
  • 6,275
  • 3
  • 31
  • 39
  • Thank you for providing such an informative and helpful answer. And the naming scheme I mentioned was purely for example's sake. I'm not _that_ stupid. Cheers! – mmmeff Dec 27 '11 at 20:30