tags:

views:

516

answers:

9

I'm currently working on a project that contains many different Eclipse projects referencing each other to make up one large project. Is there a point where a developer should ask themselves if they should rethink the way their development project is structured?

NOTE: My project currently contains 25+ different Eclipse projects.

+6  A: 

My general rule of thumb is I would create a new project for every reusable component. So for example if I have some isolated functionality that can be packaged say as a jar, I would create a new project so I can build,package and distribute the component independently.

Also, if there are certain projects that you do not need to make frequent changes to, you can build them only when required and keep them "closed" in eclipse to save time on indexing, etc. Even if you think that a certain component is not reusable, as long as it is separated from the rest of the code base in terms of logic/concerns you may be well served by just separating it out. Sometimes seemingly specific code might be reusable in another project or in a future version of the same project.

neesh
Some of them are, but I would say probably about 75% of them are not reusable on their own.
Ryan Thames
Ryan- see my response in the second paragraph.
neesh
@neesh - I see. I should have said they're not separated in terms of logic.
Ryan Thames
+1  A: 

At a former job the entire application was more then +170 projects. While it was rarely necessary to have all projects checked out locally, even the 30-40 projects constantly in our scope made reindexing, etc. very slow.

Ruben
Wow. That's terrible :(
Ryan Thames
To be honest I could not remember if it was 170 or 270 projects so I erred on the safe side. But like I said, we didn't need all projects checked out locally.
Ruben
lol, that is amazing :D Why so many projects? Do any of them have more than 20 classes?
01
+1  A: 

Yeesh. One Project for each Project. If you are using reusable projects, make them into a library for heavens sake. Break the none re-usable projects into packages, that's what they are there for.

WolfmanDragon
+1  A: 

Create jars for the projects you don't work in often. That should greatly reduce the clutter. If you work on all the projects often, then you can add targets to your build that will jar up the respective projects for you, which condenses everything down to one file that you can then include on the class path.

Mongo
+3  A: 

When compiled, a project would typically result in a jar. So if your application consists of potentially reusable components, it is ok to use a project for each.

I'm a big fan of using a lot of projects, I feel that this "breaks down" large things beyond what I can do with packages, and helps me orient and navigate.

Of course, if you're developing Eclipse plug-ins, everything would be a project anyway.

The only thing I would watch out for has to do with your source-control and it's ability to handle moves of files between projects. Subclipse had been giving me trouble with it, or maybe it's my SVN server that did.

Uri
+2  A: 

If your project has that many sub-projects, or modules, needed to actually compose your final artifact then it is time to look at having something like Maven and setting up a multi-module project. It will a) allow you to work on each module independently without ide worries and allow easy setup in your ide (and others' IDEs) through the mvn eclipse:eclipse goal. In addition, when building your entire top level project, maven will be able to derive from list of dependencies you have described what modules need to be built in what order.

Here's a quick link via google and a link to the book Maven: The Definitive Guide, which will explain things in much better detail in chapter 6 (once you have the basics).

This will also force your project to not be explicitly tied to Eclipse. Being able to build independent from an ide means that any Joe Schmoe can come along and easily work with your code base using whatever tools he/she needs.

whaley
+1 Just use maven and binary dependencies
Pascal Thivent
A: 

Hell, we have more than 100. Projects don't cost anything.

John Stoneham
+1  A: 

An additional method is to create many different workspaces. The benefit of separate workspaces is that you can remove some of the visual clutter/ performance overhead of having lots of projects. You can use targets to jar up all of you projects and put them in a repository so you can reference them in each workspace.

Milhous
A: 

That's a hard question and answers span from having one eclipse project at all to having one eclipse project for every single class.

My bottomline:

  1. You can have too few projects, and never too many (of course use automation e.g. mvn eclipse:eclipse)
  2. Use -Declipse.useProjectReferences=true/false when using maven to switch workspace mode btw jar and project dependencies
  3. Use mvn release plugin to generate consecutive releases (automatic version increase)
  4. Multiple projects gives you independent versioning which is extremely important. E.g. one dev may work on a new version of a module while you still depends on the previous one and you at some point decide to upgrade to the newer version(possibly by increasing its version in pom.xml dependency section). Or in other scenario if one project contains a bug you downgrade to its previous version.
  5. Multiple projects makes you think about the architecture more than if you have just packages.
  6. Multiple projects generally make architectural problems evident more than if you have just one project. Anyone would like to comment on this?
  7. You never know if you project evolves into OSGI/SOA/EDA where you need separation.
  8. Even if you're 100% sure that you projects will be deployed as one jar in an old way in a single jvm, it still does not hurt(mvn assembly plugin) to have multiple eclipse projects for logically independent pieces of code

BTW, the project I work on is divided into 24 eclipse projects.

MaciejZywno