Office Hours — Today, June 19

Yesterday, June 18

Jun 19
3:50 PM
Mark M.
has entered the room
3:55 PM
Mark M.
turned on guest access
4:00 PM
Paul R.
has entered the room
Paul R.
Greetings once again.
Mark M.
hello, Paul!
how can I help you today?
Paul R.
Got a couple of questions. First one is a build issue with kapt.
4:05 PM
Paul R.
View paste
The build gives me these warnings: Annotation processors discovery from compile classpath is deprecated.
Set 'kapt.includeCompileClasspath = false' to disable discovery.
Run the build with '--info' for more details.
Where is this supposed to be added?
Mark M.
if I had to guess, as a top-level closure in the Gradle script
View paste
kapt {
  includeCompileClasspath = false
}
Paul R.
Unfortunate that it is a guess. :-)
But easy enough to try.
Mark M.
I haven't seen that message, though depending on where/how it shows up, I might not be noticing it
you could just have kapt.includeCompileClasspath = false directly, as that is syntactically identical to the closure I pasted in
Paul R.
I'm using 5.5 beta Gradle plugin as it fixes an illegal state exception for the app I'm working on.
Mark M.
oh
yeah, that's 0.3.9 ahead of where I am right now :-)
Paul R.
I also see this: Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the testAnnotationProcessor configuration.
Familiar to you?
Mark M.
I haven't seen that error message, but I ran into a problem that resembled it recently
though it would be testKapt, I think
4:10 PM
Paul R.
Shall I try my next issue, recycler view.
Mark M.
um, sure!
Paul R.
ok, I am using a FAB button to trigger the network load of some Movie objects which I want to get added to the RecyclerView adapter. The recycler gets set up in a fragment. The FAB listener is in the main activity. How would you get the new data to the adapter cleanly?
Mark M.
why is the FAB listener in the activity, instead of the fragment?
er, instead of in the fragment?
I mean, you can keep it there, and have the activity call a method on the fragment, if you want
Paul R.
The setup was originally part of a Basic Activity courtesy of the Android Studio wizard which set it up with a CoordinatorLayout...
Mark M.
ph
er, oh
in terms of the data flow, though, I don't know what your overall architecture is
4:15 PM
Mark M.
in the pattern that I have been using in *Exploring Android* and *Elements of Android Jetpack*, I would have the fragment ask its viewmodel for the data
the viewmodel would work with the repository to get the data on a background thread
the viewmodel would then emit the data, perhaps as part of a view-state, via LiveData
Paul R.
Flat for now. It basically uses your ToDo code but I threw out DataBinding. I think it sucks dead moose balls. :-)
Mark M.
yeah, I can understand that
Paul R.
I have not hooked up a viewmodel yet but I like the idea.
Mark M.
the fragment would observe the LiveData and update its adapter (e.g., call submitList())
Paul R.
I believe you cover this in the ToDo app. Correct?
Mark M.
yes
at least, in the *Exploring Android* one
Paul R.
That's the one.
Mark M.
see "Using a Unidirectional Data Flow"
Paul R.
Ok, I'll look at that code and use that approach.
Mark M.
and the two chapters after it
FWIW, I also cover the same pattern, with different apps, in the latest *Elements of Android Jetpack*
Paul R.
As for databinding, I followed your setup and tried to morph the code to my app. Debugging the result was worse than pulling teeth.
Mark M.
I used it mostly for adherence to the Jetpack philosophy
and, as it turns out, with Jetpack Compose, data binding is likely to be toast in the long term
Paul R.
Good to know about the Jetpack stuff. I have not yet consumed that book.
4:20 PM
Mark M.
it's the second-generation replacement for the core chapters of *The Busy Coder's Guide to Android Development*
and the back 25% or so of the book all uses the unidirectional data flow pattern
though mostly sans fragments -- I only used fragments if the sample needed multiple screens
Paul R.
What is the background for this "universal data flow pattern" . Cannot say I've heard or seen much about it.
Mark M.
whoops, I meant unidirectional
basically, having immutable data flowing through the system, with clear points for where that data gets replaced, rather than updated in-place
Paul R.
I think that might have been me.
Mark M.
so, in the ToDo stuff, if you have gotten to the point where I start talking about "motors", my motor classes are engines of a unidirectional data flow
the UI (activity fragment) receives immutable view-states that it uses to populate the UI
the UI calls functions on the motor based on user input
Paul R.
Ah yes, now it is ringing a bell.
Mark M.
the motor does the work with the repository to actually affect real changes (database, network, etc.), then emits a fresh view-state
Paul R.
You had a very nice picture if memory serves.
Mark M.
IMHO, my diagrams aren't the prettiest, but yes, I think I have some diagrams
4:25 PM
Paul R.
Although that could have been a blog post I chased down after reading the material.
Mark M.
I have more similar ones in *Elements of Android Jetpack*, in the "Adding Some Architecture" chapter
it's a pattern that has been gaining popularity, sometimes referred to as Model-View-Intent, an name that totally sucks in Android
Paul R.
Personally, I think all these MV* things are a dis-service.
Mark M.
it's definitely a fair bit of alphabet soup, and there's not a lot of agreement over the details of any one of the patterns
which is why I tried to steer away from those terms in these second-generation books
Paul R.
I do believe strongly in Clean Architecture, which to me means develop code that adhere's to good coding principles.
And keep projects small. Too often I see simple projects turn into behemoths, hence the need to add structure. I like to use many artifacts so that my app is small. Put all the smarts into libraries developed with IntelliJ rather than keeping everything Android aware.
4:30 PM
Paul R.
fwiw.
Mark M.
there certainly are arguments in favor of that approach, though I think having a multi-module Studio project is a more common way of addressing the concerns
Paul R.
I'm going to get back to my code and follow up with your suggestions. Thanks and talk to you later.
Paul R.
has left the room
4:55 PM
Mark M.
turned off guest access

Yesterday, June 18

 

Office Hours

People in this transcript

  • Mark Murphy
  • Paul Reilly