Sunday 15 December 2019

Kotlin Tutorial

https://www.journaldev.com/19467/kotlin-let-run-also-apply-with

MVVM stands for Model View ViewModel and it is a design pattern that is used to build 
softwares. MVVM helps us to separate the Business Logic of our Application from the Views or UI.


Model : This is responsible for handling the data in the application. Model cannot directly interact with Views, but it interacts with ViewModels and then Views with the help of observables. (Sounds confusing right? Don’t worry in the course we will cover every step in detail).
View: This is the User Interface of our Application. It should not contain any application logic.
ViewModel: It is basically a link between Model and View.The ViewModel class is designed to store and manage UI-related data in a lifecycle conscious way. The ViewModel class allows data to survive configuration changes such as screen rotations. 
Architecture Components provides ViewModel helper class for the UI controller that is responsible for preparing data for the UI. ViewModel objects are automatically retained during configuration changes so that data they hold is immediately available to the next activity or fragment instance. For example, if you need to display a list of users in your app, make sure to assign responsibility to acquire and keep the list of users to a ViewModel, instead of an activity or fragment.

LifeCylerOwener and LifeCylerobserver
android mvvm architecture

Advantages of using MVVM

Now let’s talk about what are the advantages of using MVVM in your android project.
  • If you use MVVM it will help you structuring your code in a nice way so that it is easy to understand for a new developer.
  • Using MVVM makes your project maintainable as everything is well organized and making changes are very easy.
  • Testability is easy with MVVM because all modules are independent and testable.
  • MVVM enhances the re-usability of the code.

     

       Coroutines