Upload
colleen-barber
View
226
Download
0
Tags:
Embed Size (px)
Citation preview
Introduction to programming
Carl SmithNational Certificate
Year 2 – Unit 4
Unit objectives Apply simple analysis and design
techniques to the software development process.
Develop basic high-level code using an appropriate procedural programming language.
Use suitable testing methods to ascertain the correctness of a working piece of code.
Produce appropriate documentation for a given program application.
Programming languages
Pascal is one language among others such as:-C, C++, VB, JAVA, COBOL, ADA, BASIC, Fortran…Each has strengths and weaknesses for various tasks, for example COBOL is ideal for data processing
Why Pascal? Experts consider Pascal is ideal for
students studying computer science courses because:- It forces structure, very “elegant” “Easy” to learn Very powerful
Blaise Pascal, 1623-1662
The Pascal language was named after the 17th century mathematician, Blaise Pascal who invented a calculating machine called “the Pascaline” which could add and subtract and worked with eight rotating gears. Tax clerks of the era viewed it as a threat to their jobs and it was never adopted!
Program development
Good program development is performed in 4 main steps…
(which match the unit objectives - strangely…!)
Analy se
Test
W riteDoc ument
Program development…In fact there are 6 steps:-1. Analyse the problem2. Develop algorithm3. Write code4. Run the program5. Test the results6. Document the program
} Step 2
Analysis Phase Analysis is not a trivial task Before you can code you need to know
exactly what you are to do You need a clear and precise statement of
what is to be done You need to understand what data is
available and what is to be assumed You need to know what output is desired
and the form it should take
Development (Develop/Write/Run) Phase Develop an Algorithm, which is:-
“A finite sequence of effective statements that when applied to a problem, will solve it”
Write code for the program when the algorithm solves the problem
(Compile) and Run the program:-At this point you may discover typing or
logic errors!...
Testing phase Test that the results are correct and in the
form you like Prove that your program produces the
correct solution in all cases:-e.g. with arithmetic operations this may mean
checking with a calculator or even pencil and paper!
After this phase you may need to go back to the development or even analysis phases so the whole process becomes a “cycle”
Documentation phase It is very important to fully document a
working program He writer knows how the program works
(hopefully!) but if others are to modify it they must know the logic used
Documentation can also be included in the development phase as remarks within the pseudo and actual code
Developing Algorithms Algorithms for solving problems can be
developed by:- Stating the problem Dividing the problem into major sub-tasks Dividing each sub-task into smaller tasks Repeating the process until each task is easily
solved This is known as “Top Down” design
Software “Life-Cycle” Analysis Design Coding Testing/Verification Maintenance Obsolescence
What is programming? Giving the computer a logical set of
instructions to perform a specific task
That is, taking the design algorithm and converting it to code that the computer “understands”
Compiled v Interpreted Languages either run “Interpreted” that is
each line of code is interpreted into pseudo machine code (binary) at run time
Or Compiled, which is the whole program is compiled, prior to running it, into pseudo machine code
Interpreted languages tend to be slower in execution but are easier to develop and debug because the interpreter is available to pin point errors at run time
Pascal is a compiled language but the compiler is part of the “Turbo Pascal” development environment
Turbo Pascal 7 MSDOS based environment Therefore 8.3 filenames Support for the mouse but mainly
used via the keyboard Runs in a window or full screen
under Windows 95/98 or 2000
Turbo Pascal v7 – Main
Turbo Pascal v7 - Editor
Output name program
Program Components Remarks – “Self documenting code” Program Structure Declarations – Variables/Constants & Data
Types Input, Output & Formatting Arrays Decisions – “IF” Iteration - Looping Arithmetic and regular expressions Commands, Procedures and Functions :–
In Built and User Defined
} “Nesting”
Pascal - Program StructureProgram <name>;Uses Crt; - output to screenConst<list of constants>Var<list of variables><list of subprograms>BEGIN
END.
}}
Program Name
Declarationsection
Executablesection
Summary We covered:-
National Certificate Unit 4 objectivesThe software development cycleThe software life cycleIntro to Turbo Pascal 7Program Elements and structure
Any Questions?