Sunday, April 28, 2013

Native Android Client Architecture And Frameworks

Hi guys,

We all know principle of kiss. We should keep our software architectures simple as possible. One way to do that is decide architecture and narrow down the problem before going for solution/decisions. Choose good frameworks/plugins, this will make your code simple and readable. And of-course this strategy encourages re-usability, which is a way of fast development.


In this post I will try to simplify client application architecture (android client-server model) and provide list of famous frameworks. To solve solution of

  • Threads
  • Network operations
  • Cache/database
  • Re-usability 



Flow of application will be like below




So upon request or event trigger

  • First apply validations
  • Call service to execute request
  • Service with execute it can initiate thread to fetch data from server, or read from database(cache) or other facilitate other kind of requests
  • Service will return model, some data or exception
  • Services here are not android service. This layer helps you to reuse code in activities/fragments.

So what frameworks we can use in this architecture

   1.   View (Activity/Fragments)
           For view we have 
  • Robojuice  It help to bind xml view(gui), resources with objects. These annotation reduce line of code and enhance readability. 
  • Actionbarsherlock. Helps in managing navigation between view, standardization of actions for view, menu buttons on page for android 4.0+   
  • Droid4me helps you handling activity/fragment life cycle, exception handling , thread management, intra-component communication, file download management.
   2. Validations
  •  You can use my work utils jar.
  • Apache commons-validator, has xml validations and common validation methods (email addresses, dates, URLs, etc.)
   3. Thread
  •  For thread you can use Async tasks
  • You can use Robospice. It provides solution for threading, parsing data (xml, json), notification to view, exception handling.
  • You can use Droid4me for thread management.
   4.  Database manager
  • OrmLite use to create persist objects. So you dont need to populate objects after query and write code for operations like insertion, deletion, update etc your self.
  • Sqlitegen, use to create DAOs(data access object), easy to convert query results into object. 
  • ActiveAndroid allows you to save and retrieve SQLite database records without ever writing a single SQL statement. Each database record is wrapped neatly into a class with methods like save() and delete().
   5.  Network Manager 
  • Spring Restful helps communicating with servers over http, https protocols, methods can be post, get, put, delete. You can parse response direct into json, xml with the support of gson, jackson and other parsers for xml and json. (Recommended)
  • Use  Android-query to get json, xml, inputstream, files from server.

No comments:

Post a Comment