Apr 24 | 3:50 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Apr 24 | 4:00 PM |
Eric | has entered the room |
Mark M. |
hello Eric!
|
Eric |
Mark!
|
Mark M. |
how can I help you today?
|
trocchietto_Ivano | has entered the room |
Mark M. |
(BTW, hello, Ivano -- I will be with you shortly!)
|
Mark M. |
Eric: how can I help you today?
|
trocchietto_Ivano |
(OK)
|
Eric |
What is the difference between a source of truth and a cache? Is the latter a temporary set of data
|
Mark M. |
yes
|
Mark M. |
for example, your Web service might be the "source of truth", but you hold onto a recent response in memory to save bandwidth and time, rather than re-requesting the data
|
Apr 24 | 4:05 PM |
Mark M. |
caching is not an Android thing -- you see it all over computer programming: https://en.wikipedia.org/wiki/Cache_(computing)
|
Eric |
Is Room considered a source of truth or a cache? I can use it to prevent an api call but it is stored in disk instead of memory due to persistence
|
Mark M. |
a SQLite database managed by Room could be either
|
Mark M. |
it all depends on how you use it
|
Mark M. |
for a note-taking app that stores its notes purely in SQLite, SQLite is the source of truth
|
Eric |
I guess what I'm getting at is when to decide to use a memory cache or a room db cache?
|
Mark M. |
that's a several-hour discussion, tying in details like the particular purpose of the app, where and how data gets stored and moved around, etc.
|
Mark M. |
actually, to be fair, it would only be several hours for a significant app -- the smaller the app, the shorter the architectural discussions
|
Eric |
do you talk about it in any commonsware material? One consideration would be lifecycle of data, memory gets cleared once an app process is done. Another would be performance since we don't want to store something large like images in memory
|
Mark M. |
"do you talk about it in any commonsware material?" -- no, because it is not really related to Android, any more than it is related to Windows or Firefox
|
Mark M. |
your considerations are quite accurate, and that's why the details of what you cache and where depend a lot on the data, where it is coming from, and how you are using it
|
Apr 24 | 4:10 PM |
Mark M. |
for example, caching a Room database in a Room database is kinda silly :-)
|
Eric |
lol
|
Eric |
OK
|
Mark M. |
caching Web service responses in a Room database may or may not make sense, depending on the details
|
Eric |
true
|
Mark M. |
my books focus on Android first and foremost, so while I might talk about "this is how such-and-so caches data", I am not trying to teach the concepts of caching or the strategies for choosing what to cache when
|
Eric |
sure no prob :)
|
Mark M. |
let me take a question from Ivano, and I'll return to you shortly
|
trocchietto_Ivano |
well, I do not get the purpose of this flowOn operator, why `i should care about where to move the thread if I use coroutines that are going to solve this problem with the coroutine scopes and the withContext?https://kotlin.github.io/kotlinx.coroutines/kot...
|
Mark M. |
flowOn() is merely a convenience
|
trocchietto_Ivano |
that is an euphemism to say that is a nonsense?
|
trocchietto_Ivano |
or maybe is for granular operations?
|
Mark M. |
no, more that there are other ways of solving the same problem, such as having your collect() (or other terminal operator) be inside a withContext(...) {} lambda that sets the context
|
trocchietto_Ivano |
ok
|
trocchietto_Ivano |
I do not have other questions thanks Mark, I would go back to netflix
|
Mark M. |
yeah, I can't compete with that
|
trocchietto_Ivano |
thanks && bye Eric
|
trocchietto_Ivano |
well, sometimes your Axotixl in klassbook
|
Apr 24 | 4:15 PM |
trocchietto_Ivano |
or the quotes to blowing in the wind are pretty funny
|
trocchietto_Ivano |
bye
|
Mark M. |
I try to keep things light and unpronounceable
|
trocchietto_Ivano |
ahahah
|
Mark M. |
OK, Eric, back to you! do you have another question?
|
trocchietto_Ivano |
byew
|
Eric |
Can I use SharedPreferences to store an auth token? Instead of using android TokenManager
|
Mark M. |
sure
|
Mark M. |
usually, a token like that is represented as a string, or can be converted to and from a string
|
Mark M. |
so, you can store it wherever you store a string
|
Eric |
I guess what I'm asking is is it considered bad practice. Otherwise, why would google create TokenManager if SharedPrreferences alerady exists as part of Android
|
Apr 24 | 4:20 PM |
Mark M. |
well, I can't tell you why Google does lots of crazy things
|
Mark M. |
I can tell you that TokenManager is not very popular -- if I hear it mentioned once in a year, that was a banner year
|
Mark M. |
(BTW, I'm assuming that you mean AccountManager)
|
Mark M. |
AFAIK, Google had this theory of having centralized account management on the phone, and basically few developers bought into it, possibly due to "trust issues"
|
Eric |
yes AccountManager
|
Eric |
if I clear my app data, do both my SharedPrefs and my Room DB get cleared? What about if I uninstall my app? And if I update my app
|
Mark M. |
clear app data: yes, all of internal storage for your app gets cleared
|
Mark M. |
uninstall: same
|
Mark M. |
update: nothing of your app's internal storage is touched
|
Apr 24 | 4:25 PM |
Eric |
I'm not sure nothing gets touched on update. If an app adds a column to a room db table and a user installs an update their app will get that new column
|
Mark M. |
the *update* is not doing that, strictly speaking
|
Mark M. |
*your code* is doing that, if you happened to register a migration and the migration was needed
|
Eric |
correct
|
Eric |
why should somebody use external storage over internal storage?
|
Mark M. |
mostly so the user can have independent access to the content, such as via a file manager
|
Mark M. |
or via a USB cable
|
Mark M. |
internal storage = only your app can access it (except for users who root their devices)
|
Mark M. |
external storage = other apps may be able to access it, depending on circumstances
|
Eric |
so if I am building a photo app I want to use external storage so I can upload my photos to my computer?
|
Mark M. |
removable storage = oh, crap, the micro SD card popped out and now I can't find it on this dark carpet
|
Mark M. |
if you are building a general-purpose camera app, you probably want the photos to be on external storage, specifically off of a suitable media directory
|
Eric |
wait is external storage actually only available on removable storage? I thought it was also on your phone's disk partition
|
Mark M. |
external storage = a part of the on-board flash that the user can independently access
|
Eric |
what does on board flash mean sorry
|
Mark M. |
removable storage = micro SD card, or sometimes a thumb drive
|
Apr 24 | 4:30 PM |
trocchietto_Ivano | has left the room |
Mark M. |
sorry, "on-board flash" is shorthand for "flash memory that is part of the core chips powering the device and cannot be removed without a soldering iron and a steady hand"
|
Eric |
OK I see; I appreciat it
|
Apr 24 | 4:35 PM |
Eric | has left the room |
Apr 24 | 4:55 PM |
Mark M. | turned off guest access |