Information Representation and Transformation
Perhaps the greatest hardship for new programmers is the ability to quickly grasp how to represent information to describe a "phenomenon" in a computer. In reality, the choices are very limited (numbers, strings, booleans, arrays, and objects/structures). In practice, choosing the right representation is key to making working programs. One of the key attributes of a "good" representation is the ease with which it is transformed into other valid information the computer can process.
Information Representation and Transformation
Let's start with an example. Is the representation for my age better as:
a String
"twenty-five"
a whole number (25)
a floating point number (25.62)
or even as a birthdate:
(born.month = "January," born.day = 25, born.year = 1990)
The answer lies in two questions:
What are you (the programmer) going to do with the information?
How easy is it for you (actually for the computer) to transform this information into something else?
For the above example, if you are just going to print the information for the user to read, then example 1 is…