Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Android supports MVC (Model View Controller) Structure?

I want to know, If Android Supports MVC (Model View Controller) structure ? If support then 1. What is Controller ? 2.What is Model ? and 3. What is View ?

Please clear me. I have some confusion about this.

like image 738
Helal Khan Avatar asked Aug 27 '12 09:08

Helal Khan


People also ask

Is MVC used in Android?

Most Android developers use a common architecture called MVC, or Model-View-Controller. This pattern is classic, and you will find it in the majority of development projects. It's not the only software pattern, but it's the one we'll study in this course and apply to our TopQuiz application.

What is controller in MVC in Android?

The Model-View-Controller Pattern Model — the data layer, responsible for managing the business logic and handling network or database API. View — the UI layer — a visualisation of the data from the Model. Controller — the logic layer, gets notified of the user's behavior and updates the Model as needed.

What is difference between MVC and MVVM in Android?

In MVC, the controller is the entry point to the Application, while in MVVM, the view is the entry point to the Application. MVC Model component can be tested separately from the user, while MVVM is easy for separate unit testing, and code is event-driven.

Which one is better MVC or MVVM?

MVVM is better than MVC/MVP because of its unidirectional data and dependency flow. Dependency is one way, thus it is a lot easier to decouple it when we need to. It is also easier for testing. All my projects(written in Kotlin for Android app) are based on MVVM.


2 Answers

Which design patterns are used on Android?

Model-View-Control works fine

The actual Activity class doesn't extend android's View class, but it does, however, handle displaying a window to the user and also handle the events of that window (onCreate, onPause etc).

This means, that when you are using a MVC pattern, your controller will actually be a pseudo View-Controller. Since it is handling displaying a window to the user, with the additional view components you have added to it with setContentView, and also handling events for atleast the various activity life cycle events.

In MVC, the controller is supposed to be the main entry point. Which is a bit debatable if this is the case when applying it to android development, since the activity is the natural entry point of most applications.

So, Pseudo MVC in android :

Model = Entities or Classes with main Business Logic

View = layout, resources and widgets like EditText

Controller = Activity , Adaptor

enter image description here

like image 182
prayagupa Avatar answered Sep 22 '22 09:09

prayagupa


Model = Content Provider.

Controller = Activity, Fragment or Service.

View = XML layouts.

like image 41
Bartłomiej Mucha Avatar answered Sep 19 '22 09:09

Bartłomiej Mucha