Hey, so I am working on an android application where some model objects (Item, Employee, etc...) are used on both the server side and app side.
Currently I have duplicate classes in each project for those objects, but there must be a better way...
Is there any "standard" way to handle this in android? My only thought is packaging those classes into a Jar which would then be used in both projects.
It isn't really an 'android' issue so there isn't an android-specific solution - but the same problem can occur whenever you have two sides to the same application (web-client, peer-peer, etc...). But, yes, the solution you mention - breaking the model out into a separate library and using it as a resource for both sides of the application is the right thing to do. I tend to break down such applications into multiple different projects - data model, network connection management, control elements, UI, utilities..., and piecing the projects together to get the final applications. That way I can re-use the data model if needed, and the network manager if needed, and only have to write and test the code once. Then the Android specific UI stuff goes in a project, declares the others as dependencies, and is built to an app. The same for the Web application.
The trick (I think) is to break it into pieces - but not too small to avoid fragmentation, circular dependencies, and versioning requirements...
Let's get him boys! We'll make him read this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads