Friday, July 24, 2015

MVC design pattern for android app development by using Fragments as Views and Activity as Controller

MVC design pattern for android app development by using Fragments as Views and Activity as Controller - Hallo sahabat Google Android Developer Tutorial, Pada Artikel yang anda baca kali ini dengan judul MVC design pattern for android app development by using Fragments as Views and Activity as Controller, kami telah mempersiapkan artikel ini dengan baik untuk anda baca dan ambil informasi didalamnya. mudah-mudahan isi postingan yang kami tulis ini dapat anda pahami. baiklah, selamat membaca.

Judul : MVC design pattern for android app development by using Fragments as Views and Activity as Controller
link : MVC design pattern for android app development by using Fragments as Views and Activity as Controller

Baca juga


MVC design pattern for android app development by using Fragments as Views and Activity as Controller

http://stackoverflow.com/questions/9069778/mvc-design-pattern-for-android-app-development-by-using-fragments-as-views-and



I was recently reading Fragments( haven't used this in my app though) and learnt that it can be used in phones app development.
I am thinking about using Fragments to implement MVC(model-view-controller) design pattern. Many argue that android development complies with MVC by default . But i do see Activities much like Views and there's definite lack of a controller when another activity is being/due to be launched. So i am thinking of using "Fragments" as "Views" with a single "Activity" as"Controller" and swap/add/remove the fragments as and when needed.
So my basic approach is like this.
1) The user interacts with the user interface (Fragments).
2) The controller (Activity) handles the event from the Fragments and passes it to a model(Backendthread / Service).
3) Model(Backendthread / Service) notifies the controller of models state change.
4) The controller (Activity) notifes the UserInterface(Fragments) which inturn notifies the User.
does my approach is rite or an unnecessary overhead or my perception about fragments is wrong?
Please clarify me.
shareedit
   
I would like to see an example of your code when you will have something working –  IamStalker Jan 30 '12 at 20:09
IMHO, fragments are the controller. The fragment's basket of widgets represents the view. Activities are an orchestration layer, determining what fragments (and their widgets) are needed in a given circumstance (e.g., one on a phone, two on a tablet) but otherwise having limited business logic.
That being said, Android and patterns like MVC don't necessarily go together. I don't think that Google's intention was to create a pure MVC framework.
shareedit


Demikianlah Artikel MVC design pattern for android app development by using Fragments as Views and Activity as Controller

Sekianlah artikel MVC design pattern for android app development by using Fragments as Views and Activity as Controller kali ini, mudah-mudahan bisa memberi manfaat untuk anda semua. baiklah, sampai jumpa di postingan artikel lainnya.

Anda sekarang membaca artikel MVC design pattern for android app development by using Fragments as Views and Activity as Controller dengan alamat link https://googleandroiddevelopertutorial.blogspot.com/2015/07/mvc-design-pattern-for-android-app.html

Artikel Terkait

MVC design pattern for android app development by using Fragments as Views and Activity as Controller
4/ 5
Oleh

Berlangganan

Suka dengan artikel di atas? Silakan berlangganan gratis via email