I am developing a simple Android application and it should communicate with server using REST api. Both client and server use kotlin and serialize classes to json with Jackson and API looks like:
class xRequest { .. }
class xResponse { .. }
Client and server have their own git repositories and I use Android Studio and Idea to work with them separately. This leads to class declaration duplication as they both need to know API.
What's the best way to get rid of duplication? I could move API to some third project and then build - publish - add dependency on it but that's a lot of work during development.
Is it a good idea to move them to the single project so it will look the way:
my project
api
android-client
server
Thanks
It's a classic duplication problem. What we usually do in this case?
Extract duplicated code to the separate entity and reuse it.
So, I would introduce a new pure java project called core
and add it as a dependency to android-client
and server
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.