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.
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.
Jaroslaw Adamowicz11,634 Points
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!