One of your top priorities if youíre a mobile dev is staying up to date and remaining inspired by new things, even if it means challenging your beliefs.
App developers are constantly working on new methods to simplify and shorten development process on one hand and build the best designs and user experience on the other. Each year we can see continuing emergence of new, cutting-edge techniques and tools in mobile apps development. Here we present the trends that will give you a better insight about what should be on top in year 2018.
Kotlin is a relatively recent programming language that works on the Java virtual machine. Itís developed mainly by the JetBrains programmers and since Google IO 2017 Kotlin has been the official programming language of the Android application. It has a lot of advantages, such as:
● Kotlin is interoperable with Java
● Null safety
● Extension function
● Data classes
Kotlin brings all of these features of a modern language to the Android platform. Itís an excellent fit for developing Android applications and fully supported in Android Studio 3.0. It also contains several tools to improve work with its like Kotlin Android Extensions, which can fully replace iconic findViewById().
2. Room Persistence Library
Room is part of Android Architecture components, but it is a database library so we split the description into different point. Itís an abstract layer over SQLite that significantly simplifies query building. Its possibilities are amazing and oriented towards the observer pattern. Now, itís easier to write a query using annotations.
In Room, there are 3 types of components:
● Database Ė for creating the database holder
● Entity Ė represents class and one row in database
● DAO Ė component represents a interface as a Data Access Object (DAO). Main component for defining methods which access the database
Room also integrates with RxJava and the new Live Data. The library is still in the alpha phase, so applying it to a production code can be a bit risky. Weíre looking forward to the stable version.
3. Object Box
ObjectBox is a performance-optimized mobile NoSQL database created by GreenRobot, who also created the GreenDao library. This database management system was released in a stable version in September 2017. ObjectBox is a database built from scratch, has a concise API that operates on objects like GreenDao and Realm. It supports ACID operations and Multiversion Concurrency Control (MVCC) providing safe transactions and parallelism.
ObjectBox ensures compatibility with newest trends like reactive programming, Kotlin language and Android Architecture components which Iíll present in further sections.
When developing mobile apps, you have to face several challenges. One of the most important ones is clean architecture. There are a few design patterns which help you to separate modules in your app. Creating UI code thatís simple and free of business logic makes it easier to manage. Thereís another big advantage - your code becomes more testable.
The MVVM pattern was created relatively recently and is an innovative approach to creating mobile applications for the Android system. At first glance, the MVVM pattern is very similar to MVP, which is the most popular pattern in Android development. Thanks to the use of the MVVM standard, the creation of unit tests is even simpler, because no layer is dependent on the view. During testing, itís enough to check whether the observed variables are properly set when the data model layer changes. There is no need to substitute an artificial view for testing as is in the case of the MVP pattern.
In MVVM pattern, the model layer is identical to that in MVC and MVP. It is responsible for managing business logic and fetching data from server or database. It provides the required information to the View-Model layer.
The view layer represents user interface elements and is responsible for displaying data. The View observes data exposed by the View-Model. Similarly to the MVP pattern, Activities and Fragments belong to the view layer together with control systems in XML files.
ViewModel is the responsible connection between the data layer and the view layer. Its task is to provide methods, commands and other properties that help maintain the view state, as well as manage the model as a result of actions in the view and handle events in the view. View-Model does not contain information about the view and is completely independent of the views.
5. Android Architecture Components
Android Architecture Components is a set of libraries that help design maintainable, robust and testable apps. This collection of libraries consist previously mentioned Room Persistence Library, but also contains LiveData and ViewModel components described below and Paging Library but it is still in alpha, unlike other components.
LiveData is a lifecycle-aware observable data holder, which means it respects the lifecycle of other app components, such as Activity, Fragment or Service. Therefore, you do not have to handle the lifecycle manually, because LiveData will also automatically remove the observer when the Fragment receives onDestroy().
The ViewModel class is a helper for MVVM pattern. Itís designed to store and manage data necessary for UI. The ViewModel class allows data to survive configuration changes such as screen rotations, but ViewModel does not replace onSaveInstanceState().
In conclusion, we had a few big changes in last year. The most important is that Kotlin is now official programming language for Android and in 2018 Kotlin can be more popular in Android apps than Java. Moreover, we have some new big players in Android database management systems. Both, Room and ObjectBox are worth taking a closer look at and, in my opinion, worth using. In consequence, Room can finally replace clear SQLite databases in Android and ObjectBox can be a real competitor for noSQL databases like Realm. In 2017, the Android Architecture Components were also released. Since November 2017 theyíve been available in a stable version, so we believe in 2018 these set of libraries can become really powerful.