|
|
|
|
|
by StavrosK
3518 days ago
|
|
Wow, great explanation, thank you. I thought mobile programming was at the cutting edge, given how much code and focus there is on mobile apps. I'm sad to hear it's exactly the opposite. I would have imagined mobile devs/languages would have nailed asynchronous programming by now, since mobile apps are basically one huge jumble of asynchronous events and processes. |
|
Yes, configuration changes cause a tear down and recreation of your view/controller layers, but there are several patterns to deal with this cleanly (view controllers whose lifecycle spans multiple instance of a view is one of the more common, with the view instances detaching/attaching as they come and go). If you use a Flux like pattern for handling application data state you don't even necessarily have to do that since your views are just observing data stores whose lifetime outlives the views anyway.
As for asynchronous handling, there are quite a few popular libraries that are very powerful and make it easy to compose multiple asynchronous operations, update views on changes, etc - RxJava for instance has been pretty popular for the last couple of years and is very powerful, but has a steep learning curve. There are others such as Agera (from Google itself), as well as simpler async libraries like Bolts (similar to .Net task futures).
The Android SDK itself does not contain much in the way to help with any of this though (I would avoid pretty much any of the async classes that come with the SDK such as Loaders and AsyncTask) - so you do have to research and learn about third party libraries to get to a state where you can write clean and concise code.