tags:

views:

202

answers:

4

I've got an application here that I wrote many years ago that consists of a heavy-weight front end that directly queries a database server. This application runs on about 7 dedicated workstations. There is also a web-based front-end that I whipped up that shares the same feature set, and a web-based administration too for managing and reporting on the data -- they all just hit the database directly.

The application is quite simple and I understand the problem it solves very well. It could use an update, and I don't even have access to the tools necessary to work on the GUI anymore. I've been getting into Java lately, and it seems like a rewrite of this app would be a good project to get started with.

So my question then is this:

The application will require a non-web GUI, I suppose in Swing. This is necessary for very particular reasons. The application will also require a web-based GUI with the same exact features as the Swing front that will probably be deployed as a JSR-168 portlet, and a web-based administration tool (portlet also). With my previous design I ended up with a lot of duplicate code because each component had its own code base, and I foolishly used stored procedures to help to ensure that critical calculations were at least consistent.

Where should I start? I'm having such a hard time wrapping my mind around how this should all work in the Java world. I guess what I'm having the hardest time with is how do I create an application that can have both a Swing (or whatever) front-end and a web-based front end with as little duplication as possible?

Edit: I know conceptually how this can work. What I'm asking is for advice specifically related to Java technologies. Which frameworks to consider, etc.

+1  A: 

Use a middle tier server.


Swing Client -> middle-server with spring-remoting -> database

Web Client -> middle-server with spring-remoting -> database


Web Client write once any MVC framework will work stripes, struts, even grails if you are brave rememder to keep it thin....


Swing Client write once using miglayout, and glazelist.

http://www.miglayout.com/

http://publicobject.com/glazedlists/glazedlists-1.8.0/

take a look at this posting.....

http://stackoverflow.com/questions/458817/java-swing-libraries-tools-layout-managers


Middle-server write once using jdbc cause you have the db already..

http://www.springsource.org/


database write once using whatever you like. It seems already have this....

l_39217_l
yes. The point is to stop code duplication and reduce bug....
l_39217_l
+1  A: 

You should have a project with all business logic.

Then, 2 separated projects, 1 for the web access, and 1 for the Swing application. those projects both calling the business logic API. in these 2 projects, have only presentation code

chburd
A: 

Obviously start with a unified code base. You might also want to consider whether you really do need multiple interfaces.

You want to make sure that your code does not have unnecessary dependencies. For instance, make you UI as shallow as possible, rather than the usual ball of mud. Avoid singletons, as they cause dependency hell.

It may seem very enterprisey to have a middle tier, but it also adds a lot of work. For a small group it is entirely pointless.

Tom Hawtin - tackline
+6  A: 

Build a Core that contains the business logic. Use JDepend or a similar tool to ensure that it nowhere references anything swing or anything web/jsp/servlet.

Build the two UIs: For the web version pick a webframework of your choice and call your business logic from there.

For the Swing framework you have two options: access the businesslogic through webservices (you could use RMI or whatever, but I wouldn't), i.e. the logic is on the same webserver that serves the webapp (I'd probably prefer that). The alternative is to ship the weblogic with a swing GUI. Makes the coding and debugging easier, but now you have multiple points that access the db which causes headaches when you want to use caching

In any case you should only duplicate the gui stuff, once in html/css/javascript and once in swing.

Congrats on that project it will teach you tons about design and software architecture

Jens Schauder