Question

I am developing a Spring (Java framework for server-side web-development)web application, which will respond to another client-side Java application(which uses socket communication) by a JSON object. At the same time, I'm working on both server-side and client-side Java applications.

The problem is that I have a bunch of files(say, a Json variable interfaces) that are being used at both projects. For now, I have duplicate copies of that interface, in different packages in the two projects. But this causes inconsistency, because I have to update the both files whenever I need to make a change in the interface.

Does anyone have a neat solution for this?

Thanks

Was it helpful?

Solution

You should treat your shared code at the package level and not the file level.

You should create a package of interface definitions that are used by both the client and server side of your architecture and whenever that package changes, both sides will have to change accordingly.

EDIT:

I wasn't explicit about it but zellus' suggestion about importing the common code as a jar is a good one.

OTHER TIPS

You might create a separate project for your common JSON code. Using subversion, svn:externals allow a neat integration on the source level. Importing the common code as jar file is another approach.

If you're using maven, you could create a local maven project containing all the classes you might need in different projects and add this dependency to your pom.xml which requires these classes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top