https://kotlinlang.org logo
Title
d

Duchynko

11/03/2019, 12:13 PM
Morning (from Denmark) guys. Quick question regarding "best practices". Would you add your business logic to an activity rather than a fragment? I'm talking specifically about making an HTTP request to fetch data, which are displayed in only 1 fragment. (List of students). Other two fragments don't use these data, but will perform different HTTP requests in the future. Therefore, in my opinion it would make sense to separate this logic between fragments instead of keeping everything in the MainActivity. I'll be happy to hear your opinions. Cheers.
x

Xavier F. Gouchet

11/03/2019, 1:35 PM
Business logic shouldn't be in the activity nor in the fragment. Both of those classes are meant to deal with the display of information. The business logic should be in a separate class called by your fragments.
👍🏼 4
a

Adam Powell

11/03/2019, 2:25 PM
You might find this useful https://developer.android.com/jetpack/docs/guide
👍🏼 1
l

Luca Nicoletti

11/03/2019, 2:45 PM
I thought we went back to previous Android 4.0.3
r

rkeazor

11/03/2019, 5:01 PM
Bussiness Logic should never be in neither. Put it in a ViewModel, or Presenter
👍🏼 3