Closed Kobot7 closed 1 month ago
"Is the term "magic number" is supposed to have the equivalent meaning of "magic literals"?"
Yes.
In the mock test, I thought I fixed it before releasing. This is my error. The option should be read as: "The code has an issue related to magic literal"
Noted, thank you prof!
In the mock paper question 2, it is said to be correct that "The code has an issue related to magic numbers".
Question #: 2 [1 mark] Suppose you are reviewing the code below. Assume the coding standard is similar to the one you used in the CS2113/T.
In the question, I'm assuming that the supposed "magic number" is actually referring to "ABC avenue" on line 7.
The following lines are taken from the textbook:
The textbook seems to imply that the terms vary based on the data type. e.g.
2
would be a "magic number", butError 1432
would be a "magic string". Assuming that this is true, the code in the question has an issue related to "magic strings" or "magic literals", but not "magic numbers"Is the term "magic number" is supposed to have the equivalent meaning of "magic literals"?