Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Files structure in MVVM (Android)

Tags:

using MVVM or MVP should i name packages like model, viewmodel, view and put proper classes and interfaces there or is it just a logical structure that should not be visible in classes structure?

like image 805
Jakub Kwiatek Avatar asked Mar 09 '18 19:03

Jakub Kwiatek


People also ask

What is MVVM structure in Android?

MVVM stands for Model, View, ViewModel. Model: This holds the data of the application. It cannot directly talk to the View. Generally, it's recommended to expose the data to the ViewModel through Observables. View: It represents the UI of the application devoid of any Application Logic.

What is MVVM pattern?

Model-View-ViewModel (MVVM) is a software design pattern that is structured to separate program logic and user interface controls. MVVM is also known as model-view-binder and was created by Microsoft architects Ken Cooper and John Gossman.

What is Repository pattern in MVVM Android?

The repository pattern is a design pattern that isolates the data layer from the rest of the app. The data layer refers to the part of your app, separate from the UI, that handles the app's data and business logic, exposing consistent APIs for the rest of your app to access this data.

What is project structure in Android?

Project structure settings Project: Sets the version for Gradle and the Android plugin for Gradle, and the repository location name. Modules: Allows you to edit module-specific build configurations, including the target and minimum SDK, the app signature, and library dependencies. See Modules, below.


1 Answers

If you want to go by the book, the current "correct" way to implement MVVM in Android is the Android Architecture Components set of libraries.

Read more about it here, and try this code lab. These will also show you how to name and place your classes.

But in general, you should go with what matches your app best. For smaller apps I would recommend going with M V P folders, while for bigger, more long-term ones tend to work better with folder-per-feature structure.

like image 159
Kelevandos Avatar answered Sep 29 '22 00:09

Kelevandos