EET 204 Electomechanical Devices and Systems

Report
CSC-115
Introduction to Computer
Programming
Lecture 2 - Programming Introduction
Prof. M. Higazi
What is Computer
Programming?
• The process of designing, writing, testing,
debugging, and maintaining the source code
of computer program
• In computer science, source code is any
collection of computer instructions (possibly with
comments) written using some human-readable
computer language, usually as text.
• The source code of a program is specially
designed to facilitate the work of computer
programmers
What are the quality
requirements of programming?
•
•
•
•
•
•
Reliability: how often the results of a program are correct.
Robustness: how well a program anticipates problems not due to programmer
error.
Usability: the ergonomics of a program: the ease with which a person can use the
program for its intended purpose, or in some cases even unanticipated purposes.
Portability: the range of computer hardware and operating system platforms on
which the source code of a program can be compiled/interpreted and run.
Maintainability: the ease with which a program can be modified by its present or
future developers in order to make improvements or customizations, fix bugs and
security holes, or adapt it to new environments. Good practices during initial
development make the difference in this regard.
Efficiency/Performance: the amount of system resources a program consumes
(processor time, memory space, slow devices such as disks, network bandwidth
and to some extent even user interaction): the less, the better. This also includes
correct disposal of some resources, such as cleaning up temporary files and lack
of memory leaks.
Programming Languages
There are literally hundreds of computer programming languages
available for writing instructions to the computer. Each was
developed to solve a particular type of problem. Some of the more
common programming languages are:
1. BASIC (Beginner’s All-purpose Symbolic Instruction Code) – The most
popular language in use for microcomputers. BASIC was developed as the
first language to be interactive with a user.
2. FORTRAN – The first of the high-level languages designed for scientific and
mathematical programming
3. COBOL – The most popular business language in use for larger computers
4. Pascal – Popular with computer scientists; known as a highly structured
language
5. C – Developed by Bell Lab scientists, C is widely used for writing operation
systems and utility software.
6. LabVIEW – A graphical programming language developed by National
Instruments
Programmer Tasks
Computer programmers are those who write computer software. Their
tasks usually involve:










Coding
Compilation
Debugging
Documentation
Integration
Maintenance
Requirements analysis
Software architecture
Software testing
Specification
Steps in Program Development
A series of program planning tasks and techniques must be defined prior to
writing a computer program. The following steps are to be considered:
1. Clearly state the problem – No one can solve a problem if it is not clear
exactly what is to be done. The problem statement should have three parts:
a) The output is required. A computer program is always designed
to produce some desired output. Find out exactly what output is
required before proceeding.
b) The inputs. What inputs are available, and what will you need in
order to produce the desired output?
c) The algorithm for solution. An algorithm is a list of steps
necessary to accomplish a the task. What processing must be
done to get from input to output? This will include and formulas
needed for calculations.
Steps in Program Development
2. Plan the logic of the problem – There are several
popular methods for planning program logic:
a)
b)
c)
Flowcharts
Pseudocode
hierarchy charts
In practice, you will probably find that one of these
methods works best for you. Remember, the computer
follows directions exactly in the sequence given, you
must be careful to plan each step, making sure the
sequence is correct.
Steps in Program Development
3. Code the program – Writing the program in a
programming language such as LabVIEW is called
coding. The program can be written on plain paper or
on a specially designed form called a coding form.
There is also the option of coding right into the
LabVIEW language, however this is a more advanced
level of programming.
4. Key the program into the computer – This generally
means to construct the program, one piece at a time,
into the LabVIEW language.
Steps in Program Development
5. Test and debug the program – Once the program has
been keyed into the computer, you are ready to see if it
works.
–
–
–
–
–
–
When the Start/Run command is selected, the program begins executing.
At this point, you look to see if you got the exact output you expected
If the planning was done carefully and well, and no errors were made, then you
probably got the expected output
However, if the output is NOT correct or is there is no output at all, then there
was an issue with the development of your program
Any errors that are found in your program are called bugs. The process of
finding and correcting any errors is called debugging
In order to debug your code, begin by reviewing the logic/development plan of
your program. The LabVIEW Error Handler can greatly assist in debugging
syntax errors.
Steps in Program Development
6. Complete the documentation – Documentation is used
as reference material for computer systems.
Documentations include:
•
Flowcharts, hierarchy charts, pseudocode
•
Descriptions of output and input
•
Algorithms for problem solution
•
Program listings
•
Instructions for the user
* Note: Looking back at steps 1 through 5, it is obvious that most of
the documentation has already been prepared. The last step is
to complete any loose ends and assemble the documentation
into a finished product.

similar documents