Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Packaging for Reuse

 
Jamie Jackson
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm a rookie, but I've been doing some of the setup work on a Struts app. I don't have any experience packaging modules, so I need some guidance.

Say I've got these modules:

com.myFirm.app1.module1
com.myFirm.app1.module2
com.myFirm.app1.module3

The architect wants to separate the MC from the V (as in MVC) in the package structure, so that we can easily reuse the MC pieces in future Struts apps. I further suggested separating all three layers, in case pieces of the model might be repurposed for a non-Struts app.

Just so we're straight, here's what how the architect is classifying the pieces:

M = Business Objects
V = (Struts) ActionForms
C = (Struts) Actions

Therefore, it's looking like we should do something like:
com.myFirm.app1.module1.model
com.myFirm.app1.module1.view
com.myFirm.app1.module1.controller
com.myFirm.app1.module2.model
com.myFirm.app1.module2.view
com.myFirm.app1.module2.controller

But I don't recall ever seeing such package structures. Is this prudent architecture? Please feel free to comment on all of the above. Any discussion on packaging would be enlightening.

Thanks,
Jamie
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In our project, we have the follwing seperation:

module1.model
module1.swing
module1.web
module2.model
...

you get the idea...

We don't do strict MVC - actually we are experimenting with more of an MVP approach. Anyway, we find that the navigation/presentation logic is quite coupled to the type of view, so we don't care about putting it into its own module yet (though they typically *do* go into their own java package(s)).
 
Jamie Jackson
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The architect envisions most reuse to be struts reuse, so that point of view argues for a separation of V from C, also. I don't know if this separation of V from C will actually be useful when/if the code is ever reused, but it does meet her requirement.

I see what you're doing, and it does make good sense to me. It's also probably the most practical separation.

Your structure is similar to mine, so I'm more comfortable with my structure now.

Thanks,
Jamie
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This Dependency Inversion presentation has a couple slides on different motivations for different types of packaging. Let me know if it's at all helpful. Thanks!
 
Jamie Jackson
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I read through the presentation. Nice to see a presentation by example, I get lost in abstractions, until I'm familiar enough with them.

This might help me later, when I'm refactoring the modules themselves.

Thanks,
Jamie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic