Saving Data on Android


The Single  Responsibility Principle



Download 19,28 Mb.
Pdf ko'rish
bet167/292
Sana24.01.2022
Hajmi19,28 Mb.
#407089
1   ...   163   164   165   166   167   168   169   170   ...   292
Bog'liq
Bailey J., Dominguez A., Djermanovic D. - Saving Data on Android (1st Edition) - 2019

The Single 
Responsibility Principle
.
The Single Responsibility Principle states that each class in your code should have a 
single responsibility or a single reason to change and that it should do it well. Just 
like in a company, you wouldn't want developers doing accounting stuff and you 
wouldn't want your accountants touching your code.
Also, by having each class focusing on a single task you will make your code much 
easier to maintain and test.
All right, that's enough about 
LiveData
. Let's talk about 
ViewModel
s!
Crea/ng ViewModels
The 
ViewModel
 is a part of the 
Google's architecture components
 and it's designed 
to solve two common issues that developers often face when developing Android 
apps:

When an activity or fragment is destroyed, data is lost
:d Most developers can 
restore simple data by saving it using 
onSaveInstanceState()
 and retrieving it 
from the 
Bundle
 in 
onCreate()
. However, this is not always a good approach since 
Bundle
s are only suitable for small amounts of data that can be serialized and de-
serialized. You shouldn't store 
all the data
 you're displaying and working with.


Download 19,28 Mb.

Do'stlaringiz bilan baham:
1   ...   163   164   165   166   167   168   169   170   ...   292




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish