Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Android Lists and Adapters (2015) Standard ListViews Displaying List Data (or None At All)

@BenJakuben: Separation of concerns and the Model View Controller model

While I was following along, I suddenly realized that we are including a lot of private methods in the ui classes that have nothing to do with ui, but with information retrieval. Following the model view controller model, shouldn't we be including these methods into their own separate class so that both the interface and the backend can be updated separately?

3 Answers

Where exactly are you talking about? In the MainActivity? Are you talking about the JSON data retrieval parts?

It would be completely possible to move such as the parseForecastDetails, getHourlyForecast, getDailyForecast, getCurrentDetails, isNetworkAvailable and getForecast to other classes or create their own class to use them. And for some projects that might make sense if you are using these in many different locations so that we don't break DRY principles. But in this case I do not see any harm with leaving them where they are because they are only ever used in MainActivity. If you wanted to add an update button/action to the HourlyForecastActivity and or the DailyForecastActivity then moving those functions to their own class/classes would make more sense because then you would be calling and using them in more then one location.

This is just my opinion and I am not a MVC expert especially in regards to android development.

Hope this helps.

Mustafa Ogün Öztürk
Mustafa Ogün Öztürk
3,468 Points

Leaving them where they are is not a big deal since the project is not that big but following solid principles might be a good to teach some more stuff to students.