CMPSC 201 - Ch. 1 Notes
Objective #1: Explain the differences between low-level languages and high-level
ones ranging from Assembly to C/C++ to Basic.
- Low-level languages
- use commands and keywords that are difficult for a layman to understand.
Often the commands are not full words and they are brief.
- use many individual instructions or statements to perform a task.
- run more quickly though since their instructions can be "translated"
easier by the hardware of the computer.
- can precisely control the hardware (chips, peripherals, etc.)
- The classic example of a low-level computer language is Assembly.
- High-level languages
- easier for a layman or novice to read and understand since they use
full English words and even phrases to perform instructions.
- Complicated tasks can sometimes be performed by one command or statement.
- Run more slowly since some the instructions, statements, etc. have to
be "translated" into low-level languages (such as Assembly)
before they are actually understood by the hardware.
- more portable to different computing platforms since one language can
be fine-tuned ("translated") to work with different types of
hardware
- BASIC, Pascal, FORTRAN are always considered high-level. C & C++
are usually considered to be high-level but some people classify them
as being more low-level than other high-level languages.
Objective #2: Explain the differences between interpreted languages and
compiled ones. C++ is usually compiled, while Basic is usually interpreted.
- Interpreted languages run more slowly because statements and instructions
are interpreted by an interpreter line by line. If a run-time or syntax error
is found, it immediately stops the execution of the program.
- Compiled languages run more quickly because a program is first compiled
by a compiler. The compiler checks for syntax and other errors during this
stage. The compiler also creates an object file (.obj extension for Visual
C++). Then, one must build the project which links the object file to necessary
ancillary files such as header files and an executable file is created. The
executable file can then be used independently without need of the compiler
or linker.
- The executable version of a compiled program will run more quickly than
an interpreted program. For interpreted languages, the interpreter does not
produce a standalone, executable file.
Objective #3: Explain the differences between procedural programming and
object-oriented programming (OOP).
- C, FORTRAN, BASIC, and many other languages are used in a procedural
programming paradigm. A program usually consists of sets of statements
which perform tasks. The tasks are performed sequentially and when necessary
they process data that is stored separately.
- Object-oriented programming (OOP) became popular in the early 1980's
however it had been proposed and conceptualized as early as the 1960's. Programs
usually consist of sets of statements but the cornerstone of an object-oriented
program are classes and objects. Classes provide the structure and function
for objects. An object "knows" how to perform tasks because of the
functionality that its class entails. An object also holds its own structured
data. Therefore, in an object-oriented program, objects interact with each
other allowing more efficiency and flexibility. In a procedural program, tasks
must be explicitly detailed and, to a degree, all data must be stored beforehand
in a an ordered manner.
Objective #4: List a number of common, popular languages.
- FORTRAN, BASIC, COBOL, Pascal, C, C++
- Microsoft's Visual Basic is a popular version of the BASIC language. Visual
Basic is object-based rather than strictly procedural like traditional versions
of BASIC. The next version of Visual Basic (v 7) will supposedly be object-oriented.
Objective #5: List and explain each of the Programming Process.
- The 5 steps of the Programming Process are:
- Define the problem and understand the given specifications. Create
a test plan.
- Develop an algorithm by writing pseudocode.
- Code the program by writing it out on paper first.
- Test and debug the program.
- Document and maintain the program.
- Note that the Bronson textbook considers the 3 steps of the Software
Development Procedure to be the following. They are comparable to the
5 steps of the Programming Process. You will be expected to list and describe
the 5 steps of the Programming Process and not Bronson's.
- Development & Design
- Documentation
- Maintenance
Within the Development & Design step, the following steps are detailed:
- Analyze the Problem
- What to do?
- What are the expected outputs?
- What inputs will I have?
- Develop the Solution
- Code the Solution
- Test & Correct the Solution
Objective #6: List and explain different examples of documentation.
- program description - This will consist of a few sentences in a comment
at the beginning of programming assignments submitted for this course. However
in industry this section of the program could be very lengthy (i.e. many pages.)
- algorithm development & changes - This section of documentation
also precedes the actual code. When programmers edit a program, they include
a few lines (or more) detailing the changes that they made so that other future
programmers can see what changes were made to the original implementation.
- program listing (inline comments) - These comments should
be placed along the right margin beside the actual code if possible. They
annotate the actual code which could be confusing to other programmers.
- sample test runs - This kind of documentation shows others how the
program will run and interact with the user. It can also be viewed as a partial
test plan.
- user's manual - This documentation is usually printed and exists
apart from the source code. It is often called external documentation.
- You will be expected to include a program description, inline comments within
the programs that you complete for this course. Please realize though that
software written in industry includes much more documentation as outlined
above & in our textbook.
Objective #7: List and explain the four basic types of statements: sequence,
selection (if), iteration (loops), & invocation (functions).
- Sequence statements are simply statements that naturally follow one
another from the top of the program to the bottom. For example, in the "hello
world" program all of the statements are sequence statements.
- Selection statements include if statements and switch statements
that we will learn later in this course. Selection statements are sometimes
called conditional or decision statements. An example of a selection statement
is "If I scored a 60 or higher, then I passed the course; otherwise,
I failed." There are really two possible end results of this statement.
Therefore, both paths are not followed. You cannot pass the course and fail
the course at the same time. (We will study these kinds of statements in a
later chapter.) In C++, this if statement might look like this:
if (score >= 60)
{
cout << "I passed" << endl;
}
else
{
cout << "I failed" << endl;
}
- Iteration statements allow the compiler to return to a point higher
in the program in order to continuously repeat one or more statements. (We
will study these kinds of statements in a later chapter.) In C++, this is
an example of a do loop that prints "hello world" ten times:
while (num < 10)
{
cout << "hello world" << endl;
num = num + 1;
}
Objective #8: Explain the importance of a test plan and the importance of
developing it before developing and coding the solution.
- It is absolutely necessary to create a test plan early in the Programming
Process otherwise you may overlook certain program inputs.
- In fact, it is helpful to have a different person, team, or department to
create a test plan so that the programmer who designs the algorithm and code
is "unbiased" by the test plan that has been created.
- You should include test plan items for:
- reasonable inputs
- boundary cases
- invalid inputs - This kind of test plan item will not be required on
the test plans submitted with programming assignments in this CMPSC 201
course.
Objective #9: Explain the differences between using pseudocode and flowcharts
to developing a program's algorithm.
- pseudocode, see p. 21 of Bronson
- flowcharts, see pp. 12 & 21 of Bronson
- We will use pseudocode rather than flowcharts in this course.