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 trialMichael Williams
Courses Plus Student 8,059 PointsWhy have local values at all?
I understand the concept, and while it's not duplicating code it does seem like we're adding unnecessary code and making things more verbose?
2 Answers
Taylor Michel
15,634 PointsIF Iβm reading your question properly, they reason for it is simply readability. When using external frameworks, one of the most frustrating things to deal with is bad naming conventions, as it makes it hard to understand whatβs going on when calling a function. By adding a local name to a variable, it makes it easier for the person writing/editing the function to see what they are working with, but allowing the external name to give more context to the variable that the function caller needs to pass in. This makes sharing code and working with external frameworks/libraries much nicer, even if it adds an extra word or two to the function definition.
manir Hossain
Full Stack JavaScript Techdegree Student 12,074 PointsFirst, makes no sense calling the function and specify the label, instead of writing the arguments by the order in the function constructor... and then I need to have an external and internal label, not to mention the crazy convention with the prepositions. For god sake... Hope you have an English grammar class in the Library... This is so much Apple.... This is just confusing for developers... to much to write just to assign an argument in a function.
Oziel Perez
61,321 PointsOziel Perez
61,321 PointsWhile it does make sense, I'm wondering if this is a huge hinderance to developers of foreign languages who don't understand the naming convention of prepositions. It kinda feels like apple only took into consideration the English speaking developers.
Taylor Michel
15,634 PointsTaylor Michel
15,634 PointsOziel Perez its no so much Apple, but standard practice for programming languages in general. Every language I can think of is based in English as far a variables and syntax, but the programmer is more than able to write all comments, variables, user written classes and methods are in their own language.