Why use resource ids?


#1

I’m on page 32 and I’m wondering why the author chooses to use resource ids to store references to stings vs. store the strings themselves in TrueFalse class. My apologies if this question is answered later in the book.

Thanks,

Scott


#2

Hey Scott,

I know one of the useful reasons for me is it stores all of the string literals in one area, and uses references throughout the application. This means two things: a) you can use the same string multiple times without redefining it by using the reference with resource ids and b) if you want to change the string for all the different parts, you can easily do it from one spot.

Hopefully that helps a little!

  • John

#3

I thought it was kind of odd too, but personally I’m getting used to it and starting to see the value in it. Specifically, it’s pretty useful having all the strings that the app will use stored in one place. I remember early in the book it was mentioned that it’s also good for localization (i.e. porting the app to other languages).