Module: CS1702
Lecture Topic: Introduction to Programming & Problem Solving
Week: 1
In 1936 Alan Turing created two concepts called a “Turing Machine” and a “Universal Turing
Machine”. These were used to show that the “Decision Problem” was impossible to solve.
In 1939 Alan Turing used his ideas to create a machine called “The Bombe” which helped
crack the German enigma code.
In 1948 the first computer (called the Baby) and associated computer program were
developed at Manchester University based on Turing ideas.
Computer: a device for carrying out certain types of algorithms
Algorithm: set of steps for solving a problem
Computer Programming Language: a language for describing algorithms to computers
Computer Program: a description of a single algorithm and/or problem
Computer Software: is a collection of programs that carry out a similar task, e.g Windows.
+ Computers can perform many mundane tasks faster (e.g calculations)
+ Some tasks can only be done by computers (e.g high precision robotics)
- Computers can be useless for tasks such as rating films.
Computers understand binary, sequences of zeros and ones.
A computer language is a method of allowing us to describe to a computer what we want to
do. It is then translated by the computer into binary, so the computer can understand it.
Programming Concepts
Source Code: The computer files that contain a computer program
Snippet: A smell segment of source code
Blocks: Set of statements that perform a specific task
Variables: Symbols whose value can change during the execution of the program
Statements: A computer program is made up of many statements, it is the smallest building block of
a computer program
Reserved Words: Special computer programming instructions which cannot be used for variable,
class and method names.
Syntax: Computer equivalent of grammar, languages have rules governing how statements can be
used and written.
Compilation: The process of converting code to something the computer understands (machine
code – binary)
,Module: CS1702
Lecture Topic: Introduction to Programming & Problem Solving
Week: 2
The Waterfall Methodology:
Analysis>Design>Implementation>Testing>Maintenance
Analysis: What we need to do, specify the project
Design: How are we going to do the project
Implantation: Write the program code
Testing: Thoroughly test the project (unit, black/white box testing)
Maintenance: Recording user problems and fixing the problems.
Others include, rapid prototyping (series of prototypes either evolved or trashed), extreme
programming (done in pairs, very small steps developed, each step tested) , agile dev (feedback
through testing to evolve software, user centred development)
Object Oriented Programming
Example: Java is an OOP Language
This is the process of breaking down an application into smaller objects that provide specific
functionality Object Oriented Languages were developed to solve the problems involved in
developing software such as:
- Most development effort spent on maintenance
- Making changes to large programs is very difficult
- The larger the program the more faults (exponential)
OO design/OOP must be used for dev of very large software: ~>50,000 lines of code
An object is a programming construct that usually holds data and represents a key component of a
programming problem.
A class is a description of an object
An object is an instance of a class
Problem Solving
The process of finding solutions to difficult or complex issues
Computer based solutions are faster, more accurate, some problems can only be solved by a
computer.
George Pólya – Hungarian Mathematician
-Understand the problem: What are you trying to do, what more do you need to know, is there
data, tear the problem definition apart and examine the pieces.
-Make a plan: What similar problems have already been solved, can these be
used/adapted/approach the same? Flow charts, break it down into manageable parts, what
resources are available.
-Carry out the plan: Write the program, implantation. If it doesn’t work – change/review the plan.
,-Reflection, how could things be better: Testing, does it work, does it do what its meant to,
stakeholder satisfied? Can you reuse your program, has it been designed in a reusable manner?
, Module: CS1702
Lecture Topic: Variables
Week: 3
Variables are fundamental in programming language. A variable is a symbol that is used to store a
value. The value can change during the execution of a program.
You can store a value in it, take the value out of it, add a different value in it, update the value in it
string x = “Hello World!”; Assignment and declared variable in the same line
system.out.println(x);
You can also combine a set of variables and assigning a value to each on one line as long as they’re
the same data type.
Declare a variable, they must have a name and a type. Two variables can’t share the same name.
Names must begin with an alphabetical character. You cannot name a variable after a reserved
word.
Reserved Words:
abstract, assert, boolean, break, byte, case, catch, char, class, const*, continue, default, double, do,
else, enum, extends, false, final, finally, float, for, goto*, if, implements, import, instanceof, int,
interface, long, native, new, null, package, private, protected, public, return, short, static, strictfp,
super, switch, synchronized, this, throw, throws, transient, true, try, void, volatile, while
Type Description Range
boolean Logical true/false (1 bit)
byte Whole number -128 to 127 (8 bits/1 byte)
char Single character 16 bit unicode (2 bytes)
4.94065645841246544E-324 to
double Double-precision floating point (large numbers) 1.79769313486231570E+308 (8 bytes) -ve/+ve
1.40129846432481707E-45 to
float Single precision floating point 3.40282346638528860E+38 (4 bytes) -ve/+ve
int +/- whole number -2,147,483,648 to 2,147,483,647 (4 bytes)
-9,223,372,036,854,775,808 to
long +/- whole number, larger than an integer +9,223,372,036,854,775,807 (8 bytes)
short Short integer, smaller than an integer -32,768 to 32,767 (2 bytes)
String Variable length list of characters (char) Variable length