Naming conventions Flashcards
Name two types of naming conventions.
Camel case (camelCase)
Snake case (snake_case)
Hungarian notation (strInput)
Why are naming conventions important in source code?
Naming conventions provide a clear and consistent way to label program elements, ensuring easy understanding. Effective conventions convey an element’s purpose and, if needed, its data type, enhancing programmer efficiency.
Use the pseudocode below to answer the questions that follow:
Input strFileName
dAll ← {}
elTree ← fnReadFromFile( strFileName )
elRoot ← elTree.fnGetRoot()
For elSubEl in elRoot
dAll[elSubEl.fnGetEl(“height”)] ← elSubEl.fnGetAttrib(“height”)
EndFor
a) Which variable is a string?
b) What data structure is dAll?
c) What data structure is elRoot?
d) What naming convention is being used?
a) strFileName
b) Dictionary, as it takes (key, value) pairs.
c) Element of an XML tree.
d) Hungarian notation with user-defined prefixes.