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

iOS Build An iTunes Search App Building the User Interface Configuring the AlbumListController

Loose convention - upper camel casing - for constant values.

At 06:45 Pasan says that upper camel casing is a "somewhat loose convention for constant values. Are there any more specifics to this convention? Is it only applied to static values or? I can't recall having been introduced to this convention in earlier courses.

1 Answer

Jaroslaw Adamowicz
Jaroslaw Adamowicz
11,634 Points

Hi,

I think that is very minor detail in general.

As you can see in video, he is creating private struct inside of the class. He want's to store how high is the cell in table, but avoid using magic numbers.

So in my opinion he's using this loose convention to differ constants that really only hold some specific number, having it properly named and wrapped.

It is static to be accessible even when object is not yet ready (or initialized), so it can be used always.

Back in old days with C code something similar was used, but it was in all capitals and preprocessor directives were used. For example you had like:

#define DEFAULT_X_RESOLUTION 800
#define DEFAULT_Y_RESOLUTION 600

or even better: true or false;

#define TRUE 1
#define FALSE 0

because there was no explicit bool type in C.

It was also loose convention, but clearly visible in code, as intended.

I hope that helps!

BR, Jarek

Thank you :-)