Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Nicolas Hampton
Nicolas Hampton
44,626 Points

@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.