Is it possible to encapsulate business rules (no presentation layer) into a common code base to be used by native iOS, Android and Windows Phone apps? In other words, if I was writing a game to be developed across all mobile platforms, could I write a library in C or C++ which handles all the game rules (e.g. is this a valid move) and have all platforms use this library (compiled natively on each client). Please note, this would be not be for any UI/presentation code. And I am not interested in using any of the cross-platform development tools (PhoneGap, etc).
My question is, a) is this possible, b) what languages can this be done in, and c) is this a good idea? While it would add some complexity to each client up front I'm thinking it would greatly reduce the amount of code to write (less bugs) and maintenance over time.
The two answers are I can find are C++ and JavaScript as languages that can be understood by all three platforms.
C++:
JavaScript:
I personally have not attempted to include C++ files in my apps, so mileage my vary, but the capabilities seem to be there. It doesn't seem to be a bad idea, though; on its face, it seems that a library that does business logic shouldn't have a lot of trouble on any platform, and you'll be certain that all platforms are always in sync. The one thing I would say to watch out for is performance; Android and Windows Phone seem like they might be slow if you set things up incorrectly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With