• Post Reply Bookmark Topic Watch Topic
  • New Topic

Best Practice for Sharing Constants File.  RSS feed

 
Sangel Kapoor
Ranch Hand
Posts: 162
1
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Geeks

Here is the Scenario for my Problem

Scene: We Have Android Application which is talking to the Server via RESTful web services . Now the issue is , at both the ends, i.e. in Android App we use Constants for Keys
and on Server side we use the Same Constants for Keys to fetch the data . For instance, i want to POST something to the Server with KEY="key1" and Server will fetch the value by using the
same KEY="key1" to fetch it. In doing this , i am trying to make the 2 constant files in both the projects and at all times i need to synch those. If one developer changes one file , then other need to
be intimated or atleast make changes in the other file too.


Query : Is there any best practice to keep this file maintained once , any other pattern we can use ?

Looking Forward for Awesome Answers !!!

 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use an extra project with shared classes and interfaces. Where I work we have this requirement sometimes, and we usually create a project (often xxx-rest-api) where all the REST interfaces and their request/response objects are placed. The back-end project then includes this shared project and add the implementation, and the front-end includes it for its communication (often using RESTeasy).

There is still a requirement for having both projects use the correct library version, but if you create one large Maven project with the shared project, Android project and REST project as modules, Maven does the work for you.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!