Table of Contents
I. Software Systems and Methodology – 40%
C. Programming languages and notation
1. Constructs for data organization and program control
a. Definition: In this section, data organization is not referring to anything like data structures. There are many ways to think about information and programming. Object-oriented programming has come to dominate the way we organize data and our programs. Older languages used imperative programming or functional programming. Prolog was a niche language that depended on a logical programming organization. The test seems to focus on imperative languages like C and Pascal, with a few questions about object-oriented design and Prolog.
b. Website: A great Pascal tutorial can be found here. http://web.mit.edu/taoyue/www/tutorials/pascal/
c. Website: A decent C tutorial can be found here. (If you know of a better one, please email me.)
2. Scope, binding, and parameter passing
a. Definition: All data and procedures in a program have a name. The scope of that name refers to which parts of the program can access the name. For example, if a variable is local to a function, then it can only be used in that function.
b. Definition: When a name is attached to a specific piece of data or function then we say they are bound together.
c. Definition: If you call a procedure and provide values for the called procedure to use, then we call it parameter passing. The values are the parameters.
d. We use names to identify variables, types, functions, etc. Lexical scope (or static binding) is done at compile time. Dynamic Scope is done at the time the call is made to the name.
e. There are three ways to pass parameters between functions (procedures). Call-by-value passes only the value of the parameter. In call-by-value, the original variable and its value become disconnected. Call-by-reference passes the memory location of the original variable. So, the new variable (in the called function) holds a memory location and not a value. The value can be changed by using the memory location appropriately. Call-by-value-result (also known as copy-in/copy-out) also changes the original variable, but it only changes the variable at the end of the called function. In call-by-reference, if we change the new variable, then the original variable is also changed. Call-by-name passes the name of the argument. This differs from call-by-reference, because it does not pass a memory location. Arguments to macros are a good example of call-by-name.
3. Expression evaluation
a. Definition: Any set of code that returns a value when it terminates is an expression. Mathematical formulas are the best example of this (e.g. 3+4). The order of operations of a mathematical expression is an example of expression evaluation in a programming language.