简体   繁体   中英

Design Pattern for J2Objc Type Projects

j2objc is great to develop shared projects across iOS, Android and Web. For me it seems to be clear that it is a good practice to create four projects:

  • shared code
  • web
  • ios
  • android

Also the MVP seems to be reasonable for these kind of projects. When using this pattern I guess that the Model and the Presenter go into the share code project and the view goes into the platform specific projects. From my understanding transport mechanisms should go into the shared project as well or do they belong to each platform specific project?

Are there any best practices or recommended design pattern which are great for these type of projects which share a lot of code?

MVP is a great pattern, and you're right about the Model and Presenter being portable. We've found a close correlation between how easy code is to test to how portable it is, and one reason MVP was created is so more component code can be tested with simple JUnit tests.

I'm not sure what you mean by "transport mechanisms", though. Do you mean HTTP requests? If so, URLConnection/HttpURLConnection should be portable on all platforms but GWT.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM