jambit ToiletPaper 120

Android Architecture Components

Problem: A good software architecture from the beginning

As well known from building a house, a good architecture is the basis for the success of a project – also in software development. Since later changes are usually complex and expensive, a good basis should be created as early as possible. I would like to introduce briefly, how this can look like in an android app.

Solution: Architecture Components within the Android Jetpack

With the introduction of Android Jetpack, Google has combined a lot of components for app development. In this package you will also find the so-called "architecture components". They do not only save us a lot of work during the development process, but are also recommended in the guide to app architecture. How to use these architecture components is demonstrated in an architecture based on the Model-View-ViewModel (MVVM) pattern. The following is a brief overview of the individual components and their benefits:

  • Activity/Fragment: Activities and Fragments are not part of the "architecture components", but are basic components in the development of android apps.
  • ViewModel: manages the UI-relevant data. Unlike the Activity, the ViewModel exists independently of the activity lifecycle.
  • LiveData: is an observable data container which automatically notifies the Activity/Fragments of data changes without requiring an explicit call to the ViewModel. However, the lifecycle of the component is respected and thus memory leaks are avoided.
  • Repository: recommended as "best practice", even if it’s not an independent android component. It allows us to separate the ViewModel from the actual data source, which is especially helpful when we have to get and synchronize our data from different sources, as shown in the graphic on the right.
  • Room: is a library encapsulating and simplifying access to the SQLite database. Room works a lot with annotations (e.g. @Entity, @Dao) and thus reduces unnecessary boilerplate code.
Architecture Components within the Android Jetpack: Overview & Benefits

Further Aspects

---

Author: Stefan Baumgartner / Software Architect / Business Division Banking & Insurance

Graphic source: https://developer.android.com/jetpack/docs/guide; Portions of this page are reproduced from work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Android Architecture Components

Wir verwenden Cookies, um unsere Webseite für Sie zu optimieren. Mit dem Besuch unserer Webseite erklären Sie sich damit einverstanden. // Our website is using cookies to improve your experience. By continuing to browse the site, you are agreeing to our use of cookies.

Weitere Informationen finden Sie in unserer Datenschutzerklärung. // For more information, please refer to our privacy policy.