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 Build an Interactive Story App (Retired) The Model-View-Controller Pattern Adding Custom Constructors

Why did Ben hardcode the story strings instead of putting them in the strings.xml resources?

I am not sure I get it, but would it not be better to put all the strings for the story in the strings.xml resources (eventually with a smart prefix) as Ben showed in Stage 2 with the video "Introducing String Resources"?

It was also stressed out pretty clearly by Ben, earlier in this MVC stage that we should follow the DRY (Don't Repeat Yourself) principle and SRP (Single Responsibility Principle). Now, what if we would like to make another language version of this app? Then we should change more things instead of only do some changes in some .xml files, right?

2 Answers

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

Great question! I chose to teach it this way for simplicity and clarity of teaching. I thought it would make the most sense to have all the Page data grouped together. I thought for a while about adding string resources or using a string-array resource. I would definitely recommend making the switch yourself as a good exercise.

You are totally right that the current version of the app would need to be refactored to cleanly allow other languages to be introduced. Sorry for any undue stress!

Thank you for your reply Ben! :-)

Ego Team
Ego Team
17,902 Points

Hey ben, i just finished this build a story app and my app keeps crashing when i try to go to page 5 or 6. i followed along and i cant seem to find where i went wrong? can i show you my code?

Ben Jakuben
Ben Jakuben
Treehouse Teacher

Jasper Cape , I or someone else should be able to help! Please start a new thread and paste your code and we can go from there.

Ben Jakuben
Ben Jakuben
Treehouse Teacher

By the way, in the upcoming refresh of this course (due 4/5/17), I refactored this to use string resources in what I think is a better way. :)

Wow I feel so lucky I found TreeHouse and especially this course, because I'm trying to make an interactive book. Like poltexious, I also thought that putting the strings in an xml file would be a good option. Looking forward to complete this course and waiting for that refresh course! :)

Ben Jakuben
Ben Jakuben
Treehouse Teacher

Denis Filipov here's the trailer for the refreshed course, hot off the presses from Brittney (the video producer): https://www.youtube.com/watch?v=MRiQb5iTUjg

Nice! So far so good. By the time we get the new course I hope I can follow some java tutorials because there are some concepts I've forgotten.

Yiftach Cohen
PLUS
Yiftach Cohen
Courses Plus Student 351 Points

Hi, I was trying to make the switch to the string-array resource, but I wasn't sure how so it didn't succeed.. Could you give an example of how to do it ?

How did you do it?