Writing Software

Writing Soft
ware
 
There are many different languages for writing
programmes. Programming languages are designed to be
used in particular situations.
Good programming tries to make the code written re-
usable (
modular
), so that other programmers can make use
of it in the future.  Re-usable sections of code within a
programme are called 
subroutines
.  There are two types of
subroutines: 
functions 
&
 procedures
. Really useful
functions/procedures can be bundled up in 
libraries
(external files) for programmers to use.
Most programmers use 
Integrated Development
Environments (IDEs) 
to write their programs in.  These are
programmes in themselves that provide:
1) an 
editor
 to write the programmes with
2) tools to help fix problems
3) a means of converting the programmes into 
machine
readable form
High Level Languages
 
These are used for writing applications software
This is some 
C++
.  This is
a very popular language.
The other major language
is 
Java
.
Other high level languages include Basic,
Javascript, Python, Fortran, Cobol etc.
High level languages have different advantages
and disadvantages over each other, depending on
how they are to be used.
HLL are more like English than Low Level
languages and so are easier to use and
understand.
int main() { string FullName; double Hours;
double GetHours(string FullName); FullName =
GetName(); Hours = GetHours(FullName); cout
<< "\nEmployee's Name: " << FullName; cout
<< "\nWeekly Hours: " << Hours << "
hours\n\n"; return 0; }
Low Level Languages
 
These are used for writing systems software
c7 3c 2a 3c 2a 2b 2a 5c 3c 28 5c 2a 2b 2a 5c 3c
28 5c 2a 2b 2a 5c 3c 28 5c 2a 2b 2a 5c 3c 28 5c
2a 2b 2a 5c 3c 28 5c 2a 2b 2a 5c 3c 28 5c 2a 2b
2a 5c 3c 28 5c 2a 2b 2a 5c 3c 28 5c 2a 2b 2a 5c
3c 28 5c 2a 2b 2a 5c 3c 28 5c 2a 2b 2a 5c 3c 28
5c 2a 2b 2a 5c 3c 28 5c 2a 2b 2a 5c 3c 28 5c 2a
2b 2a 00 00 01 00 00 00 00 00 00 00 00 00 00
This is 
machine code
 and
written in hex! It is
processor specific and
easy to make mistakes
in!  It is used at a very
low level.
MOV AH,09h
MOV DX,OFFSET Text
INT 21h
MOV AX,4C00h
INT 21h
Text:
DB "Hello, World$"
SEGMT ENDS
END Main
This is 
assembly
language
.  It is also
processor specific and
is the next level up
from machine code.
Algorithms
 
An 
algorithm
 is a set of rules which, if followed, will
deliver a certain result.  Programmers use algorithms
to plan their code.
 
This is a
 bubble-sort
 algorithm for sorting a list of
numbers into order.  It is written in 
psuedocode
.
Psuedocode
 
Before writing a programme in a particular
language like Java, programmers will usually
write in a generalised language called
psuedocode
.  Psuedocode is a language half-
way between English and a computer
language.  It allows a programmer to write
quickly, without needing to worry about the
exact rules of the computer language that
they will eventually end up using.
Flow Charts
 
Flow charts can help plan a programme.  They
show how data flows through the programme.
They can be used for algorithms.
The different shapes
mean different things.
The important ones you
need to know are:
input/output
decision
process
Coding 1
 
Computational thinking
 means understanding
how to represent a problem in a way that a
computer will be able to solve. This involves
breaking down problems into a series of logical
steps such as an algorithm.
Decomposition
 means breaking down a large
problem into smaller chunks that can be solved
using computing.
Abstraction
 means reducing something to a very
simple set of characteristics, chosen to be most
relevant to the problem.
Coding 2
 
Eventually, a programme written in
psuedocode will need to be written in a
specific language, this is called 
coding
.
Every language has a strict set of grammar
rules that must not be broken, this is called
syntax
.  Breaking the rules creates a 
syntax
error
 within the programme.
Syntacticly correct programmes may still not
behave as expected because of 
logical errors
.
Logical errors
 
can only be fixed by testing.
Sequence, Selection, Iteration
 
All programmes work by executing instructions.
Controlling the flow of a programme is done
through the basic processes of 
sequence, selection
and iteration.
The instructions are usually executed in order, in
sequence
.
On occasions, decision instructions (e.g. IF
statements), cause jumps in the code out of the
normal sequence.  This is called 
selection
.
Any block of code that needs to be repeated is
placed in a loop structure.  This is called 
iteration
.
Compilation vs Interpretation
 
A programme written in a high level language must be
converted into machine readable form (machine code)
before it can be run on a computer.  This is done by
translator
 software which either 
compiles
 it or
interprets
 it (a 
compiler
 or 
interpreter
).
Compilation involves converting all the 
source code
(that written by the programmer) into machine code
(
object code
) 
in one go
.  The finished compiled
machine code programme is then packaged up and can
be run again and again.  Java is a compiled language.
Interpretation involves converting the 
source code
 into
machine code 
one line at a time 
and executing it.  This
process must be repeated each time the programme is
run.  Interpreted programmes run more slowly than
compiled ones.  Javascript is an interpreted language.
Debugging 1
 
This is the process of finding and fixing
problems (
bugs
) in a programme.  
Syntax
errors
 can be fixed easily; 
logical errors 
are
harder to find.
Assuming two variables: a=5 and b=6
if (a > b)
     print(“a is greater than b’)
This snippet of Python 3.2 code shows two 
syntax
errors:
1)
No colon at the end of line 1
2)
Non-matching quotes inside the print
statement
Logical errors 
will often 
not
 prevent a programme
from running.  They may, however, lead the
programme to produce unexpected results!
Debugging 2
 
A good IDE should provide tools to help
debugging like:
1.
Setting 
watches
 on variables to show what
the variables contain at various points
2.
Allow
 
stepping
 through the programme line
by line
3.
Setting 
break points 
(places where the
programme is made to pause)
4.
Colour coded text.
Debugging 3
 
Trace variables
It can often help to present the values of
variables, at various points in a programme, in
what is called a trace table. e.g.
 
 
var=0
for x in range(0, 3)
 
var=var + 2
Slide Note
Embed
Share

The world of programming languages, from high-level to low-level, and understand the importance of reusable code through subroutines. Discover the role of algorithms and pseudocode in software development.

  • Programming
  • Languages
  • Reusability
  • Algorithms
  • Pseudocode

Uploaded on Feb 18, 2025 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Writing Software There are many different languages for writing programmes. Programming languages are designed to be used in particular situations. Good programming tries to make the code written re- usable (modular), so that other programmers can make use of it in the future. Re-usable sections of code within a programme are called subroutines. There are two types of subroutines: functions & procedures. Really useful functions/procedures can be bundled up in libraries (external files) for programmers to use. Most programmers use Integrated Development Environments (IDEs) to write their programs in. These are programmes in themselves that provide: 1) an editor to write the programmes with 2) tools to help fix problems 3) a means of converting the programmes into machine readable form

  2. High Level Languages These are used for writing applications software int main() { string FullName; double Hours; double GetHours(string FullName); FullName = GetName(); Hours = GetHours(FullName); cout << "\nEmployee's Name: " << FullName; cout << "\nWeekly Hours: " << Hours << " hours\n\n"; return 0; } This is some C++. This is a very popular language. The other major language is Java. Other high level languages include Basic, Javascript, Python, Fortran, Cobol etc. High level languages have different advantages and disadvantages over each other, depending on how they are to be used. HLL are more like English than Low Level languages and so are easier to use and understand.

  3. Low Level Languages These are used for writing systems software This is machine code and written in hex! It is processor specific and easy to make mistakes in! It is used at a very low level. c7 3c 2a 3c 2a 2b 2a 5c 3c 28 5c 2a 2b 2a 5c 3c 28 5c 2a 2b 2a 5c 3c 28 5c 2a 2b 2a 5c 3c 28 5c 2a 2b 2a 5c 3c 28 5c 2a 2b 2a 5c 3c 28 5c 2a 2b 2a 5c 3c 28 5c 2a 2b 2a 5c 3c 28 5c 2a 2b 2a 5c 3c 28 5c 2a 2b 2a 5c 3c 28 5c 2a 2b 2a 5c 3c 28 5c 2a 2b 2a 5c 3c 28 5c 2a 2b 2a 5c 3c 28 5c 2a 2b 2a 00 00 01 00 00 00 00 00 00 00 00 00 00 MOV AH,09h MOV DX,OFFSET Text INT 21h MOV AX,4C00h INT 21h Text: DB "Hello, World$" SEGMT ENDS END Main This is assembly language. It is also processor specific and is the next level up from machine code.

  4. Algorithms An algorithm is a set of rules which, if followed, will deliver a certain result. Programmers use algorithms to plan their code. This is a bubble-sort algorithm for sorting a list of numbers into order. It is written in psuedocode.

  5. Psuedocode Before writing a programme in a particular language like Java, programmers will usually write in a generalised language called psuedocode. Psuedocode is a language half- way between English and a computer language. It allows a programmer to write quickly, without needing to worry about the exact rules of the computer language that they will eventually end up using.

  6. Flow Charts Flow charts can help plan a programme. They show how data flows through the programme. They can be used for algorithms. The different shapes mean different things. The important ones you need to know are: input/output decision process

  7. Coding 1 Computational thinking means understanding how to represent a problem in a way that a computer will be able to solve. This involves breaking down problems into a series of logical steps such as an algorithm. Decomposition means breaking down a large problem into smaller chunks that can be solved using computing. Abstraction means reducing something to a very simple set of characteristics, chosen to be most relevant to the problem.

  8. Coding 2 Eventually, a programme written in psuedocode will need to be written in a specific language, this is called coding. Every language has a strict set of grammar rules that must not be broken, this is called syntax. Breaking the rules creates a syntax error within the programme. Syntacticly correct programmes may still not behave as expected because of logical errors. Logical errors can only be fixed by testing.

  9. Sequence, Selection, Iteration All programmes work by executing instructions. Controlling the flow of a programme is done through the basic processes of sequence, selection and iteration. The instructions are usually executed in order, in sequence. On occasions, decision instructions (e.g. IF statements), cause jumps in the code out of the normal sequence. This is called selection. Any block of code that needs to be repeated is placed in a loop structure. This is called iteration.

  10. Compilation vs Interpretation A programme written in a high level language must be converted into machine readable form (machine code) before it can be run on a computer. This is done by translator software which either compiles it or interprets it (a compiler or interpreter). Compilation involves converting all the source code (that written by the programmer) into machine code (object code) in one go. The finished compiled machine code programme is then packaged up and can be run again and again. Java is a compiled language. Interpretation involves converting the source code into machine code one line at a time and executing it. This process must be repeated each time the programme is run. Interpreted programmes run more slowly than compiled ones. Javascript is an interpreted language.

  11. Debugging 1 This is the process of finding and fixing problems (bugs) in a programme. Syntax errors can be fixed easily; logical errors are harder to find. Assuming two variables: a=5 and b=6 This snippet of Python 3.2 code shows two syntax errors: 1) No colon at the end of line 1 2) Non-matching quotes inside the print statement if (a > b) print( a is greater than b ) Logical errors will often not prevent a programme from running. They may, however, lead the programme to produce unexpected results!

  12. Debugging 2 A good IDE should provide tools to help debugging like: 1. Setting watches on variables to show what the variables contain at various points 2. Allowstepping through the programme line by line 3. Setting break points (places where the programme is made to pause) 4. Colour coded text.

  13. Debugging 3 Trace variables It can often help to present the values of variables, at various points in a programme, in what is called a trace table. e.g. var x Line 1 0 - var=0 for x in range(0, 3) var=var + 2 1st pass through loop 2 0 2nd pass through loop 4 1 3rd pass through loop 6 2

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#