Sipping from the Firehose at AnDevCon, Part 2
Vendor-sponsored technical conferences are mostly about the future: new products and techniques that the company has created, and hopes the developer community will enthusiastically embrace. Independent technical conferences are about the present: the challenges developers are encountering in the field as they put these tools to work, and the solutions they've created or adopted to make their apps better.
You can get the true temperature of a technology at an independent conference like AnDevCon, which I attended in Boston last week. Speakers show off their ideas for the best ways of creating products (in this case, mobile apps on the Android platform). And through the various lunches, receptions, and chance hallway chats, you can find out what developers are really doing out there.
This year, there was a clear focus on software architecture. The Android SDK, as with many application development frameworks, provides just about everything you need to build a complete app. But if you restrict yourself to the examples in Android’s documentation, the result can be overly complicated: what the industry sometimes calls spaghetti code.
The problem is the number of layers, or tiers, in a mobile app. An Android app’s user interface is defined in Java classes named activities. The user interface can be further extended with fragments, and with dialogs. But the app’s data has to come from somewhere, and it's usually acquired and defined in Java as well. So you have database, web service, and model (or entity) code, also all written in Java. Long-running actions that need to be independent of the user interface can be defined in services, but then they have to be able to share their results with the user interface elements.
And so on. If you don’t plan things out ahead of time, you can end up with a mess: an activity class that contains code for user interface, data acquisition and persistence, business logic and rich media, all in one place. This sort of code is fragile, easy to break. And it discourages adding new features, since without a clear architecture in place you can easily introduce new bugs.
The Android SDK provides some tools for sorting it out, but Google hasn't endorsed a single architectural strategy. Their preference has been to leave the field open for competing architectures from the community. The result is a lot of choice. To an architectural novice, it can feel like walking into a modern supermarket and seeing a dozen brands of coconut water. Which do I want or need? How do I decide which tastes better, which offers the best value?
The most popular architectures for managing communications between decoupled client and data-management tiers aren’t Android-specific. They’re known mostly by their acronyms: MVC (Model-View-Controller), MVP (Model-View-Presenter), MVVM (Model-View-ViewModel) and Clean are currently the most popular. (MVVM got a boost from Google when a new data binding library was introduced last year that works particularly well with that architecture).
And Android developers can clean up their code even further with open source libraries based on reactive programming. In this style, instead of a client requesting data from a back-end process, it registers to listen for events that will be dispatched when data becomes available. Mobile app developers can implement reactive programming with Android-specific libraries such as RxJava (with a subproject named RxAndroid), Otto, TinyBus, and EventBus.
You can try to sort out all of these options yourself, but at AnDevCon last week I was able to learn quickly about many of these solutions, and talk to developers who’ve actually used them.
It takes time to select and then master a new architecture. Deciding which to implement in a new project takes some experimentation, creating small pilot projects to help you wrap your head around a new approach to programming. But the resulting improvements should make it easier to add features and fix bugs in the future.
Which Android architectures and libraries have you tried, and which do you love (or hate)? Share your experiences in the comments!
Associate Manager at AB InBev India
6 年I want to learn vba can you help me
Data Analyst, Researcher at Dots ICT Institute of Technology, Ogun Nigeria |Electrical Professional
7 年Glad to learn this new skills. Android development