Prep for HN Introduction to Software Development

Download Report

Transcript Prep for HN Introduction to Software Development

Prep for HN
Introduction to Software
Development
Lecture 1
The Software Development Lifecycle
Code Basics
7/17/2015
How Computers Work
• They input (read) data from an external
source (device)
• They store the data for later use
• They can manipulate the stored data
• They can follow a set of instructions
(program)
• They can output results to an external
device
7/17/2015
Computer Basics
Computers can be viewed as being built
of four basic units -
Input, Memory, Processor, Output.
7/17/2015
Computer Memory
• The memory
part stores both
data and the list
of program
instructions
• This is very important. Changing the
program instructions in memory
changes the behaviour of the machine!
7/17/2015
Personalities
• Al-Kwarizimi was a
ninth-Century Iraqi
mathematician who
laid down sets of
rules to determine
how things work. In
a moment you will
come across the
term algorithm!
7/17/2015
Personalities
Later on, the 15th-Century
French mathematician
Blaise Pascal invented a
mechanical adding
machine for his father, the
local Tax Collector!
In 1971 Professor Nikolas Wirth invented a
computer language and called it after
Pascal.
7/17/2015
Personalities
• In 1840 English mathematician
George Boole first applied algebra to
logic problems. Nowadays all digital
computers – both the hardware and
software – are based on Boolean
logic.
• John von Neumann introduced the
idea of a program stored in memory,
in 1945.
7/17/2015
What is a computer program?
• It is a plan that has been designed to
make the computer perform some
action, to provide the answer to some
specified problem. This plan is
usually called an algorithm.
7/17/2015
Some algorithms you may
have come across already –
•Directions to the pub
•A recipe for chilli con carne
•A knitting pattern for a jumper
The directions may be very simple, or
require more technical knowledge.
7/17/2015
Programming Languages
• Programming languages such as
Pascal, Visual Basic and Java are
used for converting an algorithm
into machine language that a
computer can understand and act
upon.
7/17/2015
The Lifecycle
• Usually developers use a seven-step
process for designing, writing and
publishing computer programs. This is
called the Software Development Life
Cycle. It is easy to remember by • A Dance In The Dark Every Monday
7/17/2015
A Dance In The Dark Every Monday
Analysis
• The first step is to decide on what you
actually want the program to do.
• The end user and the programmer must
be absolutely clear about what
information is required from the
program, what can be input to begin
with, and what will happen in between.
7/17/2015
A Dance In The Dark Every Monday
Design
• In this stage, the problem can be split
down into smaller subtasks.
• Usually the designer will draw a
diagram (structure chart or flow chart)
of the problem, or write down a series
of steps in simple English
(pseudocode) showing how the
solution will be reached.
7/17/2015
A Dance In The Dark Every Monday
Implementation
• This is where the programmer takes
the design and translates it into the
programming language to be used.
• The written program (source code) is
then run through another software
program called a compiler.
• The compiler produces the finished,
runnable (executable) program.
7/17/2015
A Dance In The Dark Every Monday
Testing
• Once the program is running, it is
tested.
• The program is run using several
sets of input data. The aim is to try
and make it crash!
• The results of every test are written
up in a test log. Any parts of the
program that do not stand up to
testing can be corrected at this point.
7/17/2015
A Dance In The Dark Every Monday
Documentation
• All the documents that go with the program
are put together here - the design, a copy
of the code (program listing), the test plans
and logs, and usually some user
instructions.
• The user guide is especially
important if the program is to
be used by people unfamiliar
with the technical parts of
computers!
7/17/2015
A Dance In The Dark Every Monday
Evaluation
• Does the program fulfil the initial
requirements?
• Is it suitable for the purpose?
• Is the end-user happy with the final
result?
• How could the program be improved
or expanded?
7/17/2015
A Dance In The Dark Every Monday
Maintenance
• This step is usually necessary because the
end-user has encountered some problem,
or has thought of some improvement they
would like added in.
• We go back to the “analysis” stage, and
start again!
• It is common for the “maintenance” costs to
rise much, much higher than the original
program costs over a long period of time.
7/17/2015
The Coding Stage
• Programming languages are used to
convert the algorithm to a final computer
program.
• There are hundreds of programming
languages available for use.
• Some are more complicated than
others!
7/17/2015
Examples...
100
110
120
130
REM Hello World
REM Basic Version
PRINT ‘HELLO WORLD’
END
PROGRAM Hello (Input, Output);
{Pascal version}
BEGIN
Writeln (‘Hello World!’);
END.
7/17/2015
-- ADA version
with Text_IO;
procedure Hello_World is
begin
Text.IO_Put(“Hello World”);
end Hello_World;
/* C and C++ version */
#include <stdio.h>
main{}
{
printf {“Hello World!”};
}
7/17/2015
Comments
• All of these programs have
comments in them. This is text that
is ignored by the computer, but is
very useful to the programmer!
• It is good programming practice to
put lots of comments in your
programs. Sometimes it is not
always obvious why the code is
there!
7/17/2015
Comments
• In addition, the
name of the
programmer, the
date and the version
number should
always be included
as comments.
The Countess Ada Byron
Lovelace was the worlds’
first Computer Programmer!
7/17/2015
Hello World!
program Hello_World;
{a first Delphi program}
{written by Chrissie Nyssen 16/02/05}
{version 1.00}
{$APPTYPE CONSOLE}
uses
SysUtils;
7/17/2015
begin
writeln ('Hello World!');
readln; {this line is optional but it
stops the program
vanishing off the screen the
moment it has ended!}
Your First Program
• Your lecturer will show you how to
start up the Delphi environment.
• Type in the above program and run it.
• Remember to put lots of comments in
{curly brackets!}
• Congratulations! You are now a
Real Computer Programmer!
7/17/2015
Some Algorithm Problems
“Quick! Fetch the brandy!”
“Where is it?”
“In the blue basket on the bottom shelf of the
cupboard next to the fridge freezer in the kitchen.”
“In the kitchen, in the cupboard beside the fridge
freezer, on the bottom shelf, in the blue basket.”
Which is the better algorithm? Why?
7/17/2015
Some Algorithm Problems
Write an algorithm to
direct a visitor to
Aberdeen to the Pizza
Hut at the Beach
Boulevard. (You can
work as a group for this
one.)
7/17/2015
Some Algorithm Problems
Write down the Master Plan for
•The rest of today
•The rest of this week
•The rest of this academic year
•The rest of your life
Next week we will put this on a
flowchart, so keep it someplace safe.
7/17/2015
Some Programming Problems
•The Italian version of “Hello World!” is
“saluti tutti”. Rewrite your first program as
version 1.1 to say “Hello World!” in Italian.
•Write a program in Delphi to say “Hello” and
your name, surrounded by a border of stars.
•Implement the Pizza Hut algorithm as a
Delphi program.
7/17/2015
Next week we will...
•
•
•
•
7/17/2015
see how to draw a flowchart
learn how to write pseudocode
look at different types of data
use variables to create more
interactive programs
Acknowledgements
•
•
•
•
Lecture designed and written by Chrissie Nyssen
Materials all ©Aberdeen College 2005 unless otherwise stated
Master slide © Carnegie Training
RAM, little old lady © www.clipart.com with non-distribution
licence
• Pascal, Ada, Al-Kwarizimi stamp all public domain, courtesy of
St. Andrews University
• Pizza chef, man with plan © Microsoft
• Lecture available online at
http://abcol-ac1.abcol.ac.uk/~chrissie/PascalHome.htm
7/17/2015