简体   繁体   English

J2Objc类型项目的设计模式

[英]Design Pattern for J2Objc Type Projects

j2objc is great to develop shared projects across iOS, Android and Web. j2objc非常适合在iOS,Android和Web上开发共享项目。 For me it seems to be clear that it is a good practice to create four projects: 对我来说,很明显,创建四个项目是一种好习惯:

  • shared code 共享代码
  • web 卷筒纸
  • ios IOS
  • android 安卓

Also the MVP seems to be reasonable for these kind of projects. 对于这些项目, MVP似乎也是合理的。 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. 使用这种模式时,我猜想Model和Presenter会进入共享代码项目,而视图会进入特定于平台的项目。 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. MVP是一个很好的模式,您认为Model和Presenter具有可移植性是正确的。 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. 我们发现测试代码的容易程度与代码的可移植性之间有着密切的关系,而创建MVP的原因之一就是可以使用简单的JUnit测试来测试更多的组件代码。

I'm not sure what you mean by "transport mechanisms", though. 不过,我不确定您所说的“运输机制”是什么意思。 Do you mean HTTP requests? 您是指HTTP请求吗? If so, URLConnection/HttpURLConnection should be portable on all platforms but GWT. 如果是这样,URLConnection / HttpURLConnection应该在除GWT之外的所有平台上都可移植。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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