關於Cross Platform,是咁的

Cross Platform 既Framework,真係今期流行。 從以前唔成熟又lag又唔look native,到而家,好多solution都so far ok la。

而且對於Vendor黎講,又要壓價又要交貨,又或者對於Startup黎講,
一個mobile site既level可以解決到既問題快速上馬交兩個platform既功課,
又真係幾吸睛既。

你又Cross嗱?

而家真係好多Cross Platform tools,咩Xamarin、Talarik、React Native、Electron、Cordova ionic PhoneGap...
一大籮。而且家下個個都打正旗號話自己幾Native,真係⋯⋯開心啦⋯⋯

但係好多人對 Develop 一個 Cross Platform 既app都存在一定誤解,
今次就打算同大家一齊講講。

排名必分先後而且絕對主觀。

誤解一: Cross Platform,咁即係只需要寫好A,就會有B啦

錯錯錯⋯⋯ 我地先簡化個問題,把佢收細到Mobile App Only先。即使係咁,
呢到有最少三個Platform(唔好咁啦你班人,又稔住蝦人地Micros⋯⋯),
而每個Platform都有唔同既Config。好,我地再簡化一次個問題,
只講UI(其實應該係話最要注視既係UI,因為Data既code,行到就係行到,
行唔到就⋯⋯但都有野要注意,再講)。
等我計下所有Screen Size有幾多先⋯⋯ Android既ScreenSize就好計好多,一條Formular 就有齊:

function androidScreenSizes(w,h) {
  if ( w <= 0 || h <= 0 ) return [(w,h)];  
  return [(w,h)].concat(androidScreenSizes(w-1,h-1);
}
var ratioAndMax = [(1920,1080),(1920,1180)];
var screenSizes = ratioAndMax.map(androidScreenSizes);

講笑姐⋯⋯ 但係你明啦⋯⋯所以兩大Platform都有自己既"Auto Layout"方法,
咁先可以保障到唔同Platform之間既UI既質素。當你要用Cross Platform 既Solution時,
唔該,有關View既Code,唔好下意識當佢係一定可以共用到。

猶其係,你愈用得多Customise既Layout,你就愈會用得多Customise既Layout,
跟住就stackoverflow(Both the site and your brain)了。咁點搞好?
唔該,platform specific去寫UI同埋Test,
而且係同時不同target platforms同at least不同Ratio咁 test。

一係你少寫/小心寫;一係你唔好在意;一係你log 晒所有古怪既code;
一係唔理你成個Project係咪Test Driven,唔該,呢part真係要test。

記住,一唔小心Cross Platform 就會變左做 Cosplay。

誤解二 assert(false,(C.contain(A) && C.contain(B) && C JIT -> Native Call。

唔好理Ruby定Javascript,底個沉都係咁。而Native component === Native就係係呢一層到判定,
如果呢個Process只係Single call,好,我地唔好咁計較,當係啦;但如果呢一尐Call係不停地call,
例如一個 (n x m) table全部content都係 realtime native component render出黎既,
而且不停refresh既,個問題就起碼多左一重O(n*m)。

誤解五 你無留意到誤解四應該係誤解三而誤解五應該係誤解四

嗱嗱嗱,我唔係裝你彈弓,而係想引出人終有一疏呢個真理。Ok fine唔係你無留意,
係我打錯。咁點講都好,就係錯。錯就要Debug(好硬⋯⋯),
而Debug係Cross platform上面,就幾唔 Cross platform囉。幾唔?

幾唔 ~= (bugs) * platforms + files.reduce(filelines) * 0.00001

就係咁。

Original post from my previous site: http://povoq.blogspot.com/2017/04/cross-platform.html

Which is originally from my self host and shut down blog...

Subscribe to TechRD.in

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe