且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何$ Android和iOS之间的C $Ç共享

更新时间:2022-05-25 02:16:55

虽然情绪是合理的(你下面做不重复自己的政策),它只有务实的,如果你可以共享code在以有效的方式。在这种情况下,它不是真的有可能有一个写一次的方式来跨平台开发,其中需要code两个平台用不同的语言(C / C ++ /的OBJ-C在iPhone,Java进行Android的)。

While the sentiment is sound (you are following the policy of Don't Repeat Yourself), it's only pragmatic if what you can share that code in an efficient manner. In this case, it's not really possible to have a "write once" approach to cross-platform development where the code for two platforms needs to be written in different languages (C/C++/Obj-C on iPhone, Java for Android).

您会更好写两个不同的codebases在此情况下(在两种不同的语言)。字忠告:不要写你的Java code,喜欢它的C ++,或你的C ++ code像它的Java语言。我一数年前曾在一家公司谁了产品,他们移植从Java到C ++,他们没有写C ++ code就像是C ++,和它造成的种种问题,而不是何况是难以阅读。

You'll be better off writing two different codebases in this case (in two different languages). Word of advice: don't write your Java code like it's C++, or your C++ code like it's Java. I worked at a company a number of years ago who had a product they "ported" from Java to C++, and they didn't write the C++ code like it was C++, and it caused all sorts of problems, not to mention being hard to read.