itp © ron poet lecture 1 1 it programming introduction

27
ITP © Ron Poet Lecture 1 1 IT Programming Introduction

Upload: beatrix-baker

Post on 24-Dec-2015

220 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ITP © Ron Poet Lecture 1 1 IT Programming Introduction

ITP © Ron PoetLecture 1

1

IT Programming

Introduction

Page 2: ITP © Ron Poet Lecture 1 1 IT Programming Introduction

ITP © Ron PoetLecture 1

2

No Programming Experience

We assume that many students on this course have never programmed.

The course will be geared to these students.It is hoped that all students will be able to

program reasonably well by the end of Further Programming.

Page 3: ITP © Ron Poet Lecture 1 1 IT Programming Introduction

ITP © Ron PoetLecture 1

3

If You Have Programmed Before

The initial parts of the programming course will appear straightforward.But the approach may be different to the one you have

taken in the past.

At some point the programming ‘train’ will go past your current ability.You should be on the train for a smooth transition.Rather than having to jump onto a moving train.

Page 4: ITP © Ron Poet Lecture 1 1 IT Programming Introduction

ITP © Ron PoetLecture 1

4

Keeping Connected

You should attend the lectures even if you have programmed before.That way you notice new things as they appear.

You should attend the labs and do the labwork.You can go when you have finished.

You should read ahead in the text book.And do some of the textbook exercises in the lab.

Page 5: ITP © Ron Poet Lecture 1 1 IT Programming Introduction

ITP © Ron PoetLecture 1

5

Initial Programming Labs

You will be part of a lab group, with a tutor and a demonstrator to help with problems.

There will be labwork each week.There will be regular exercise which you

should complete during the lab.They will be marked by your tutor during

the lab.

Page 6: ITP © Ron Poet Lecture 1 1 IT Programming Introduction

ITP © Ron PoetLecture 1

6

Further Programming Labs

Later exercises will be assessed.You will have to hand them in.The programs will be submitted

electronically.So that we can run them.

You will get written feedback after they are marked.

Page 7: ITP © Ron Poet Lecture 1 1 IT Programming Introduction

ITP © Ron PoetLecture 1

7

Talking with Computers

Computers are machines and don't understand anything.

They cannot resolve ambiguities by drawing on experience.

Computers are unbelievably pedantic about grammar.

Page 8: ITP © Ron Poet Lecture 1 1 IT Programming Introduction

ITP © Ron PoetLecture 1

8

Machines

Because computers are machines, like DVD players.They will not ‘understand what you mean’ if

you get the instructions slightly wrong.

You need to develop a mental model of how computers work to be able to program them well.

Page 9: ITP © Ron Poet Lecture 1 1 IT Programming Introduction

ITP © Ron PoetLecture 1

9

Steep Learning Curve

Programming can be difficult at first.It requires good problem solving skills.It will be hard at first, and requires

persistence.Suddenly everything will click and

programming will make sense.

Page 10: ITP © Ron Poet Lecture 1 1 IT Programming Introduction

ITP © Ron PoetLecture 1

10

Ambiguous?

If you ask a person if they want fries or salad, they may replyI'll have the salad, I value my health, orI'm a Glaswegian, so it's fries.

A computer would replyYes!Because it will choose one or the other.

Page 11: ITP © Ron Poet Lecture 1 1 IT Programming Introduction

ITP © Ron PoetLecture 1

11

Grammar Freak

I might say "Glasgow is the best university in it's region"

You might replyYes, that's why I'm here, orYou would say that wouldn't you.

A computer would replyGrammatical error!

Page 12: ITP © Ron Poet Lecture 1 1 IT Programming Introduction

ITP © Ron PoetLecture 1

12

Does Not Understand

We could state the formularadius = 10CircleArea = 4 * radius * radius

A human would sayWhere did you learn your maths?

A computer would sayThe area of the circle is 400!

Page 13: ITP © Ron Poet Lecture 1 1 IT Programming Introduction

ITP © Ron PoetLecture 1

13

Low Level Computer Languages

The Central Processing Unit (CPU) of a computer works with very basic instructions.Even the simplest of operations involves a large

number of very tedious steps.

Fortunately most programmers don't have to program at this level.Although some do.

Page 14: ITP © Ron Poet Lecture 1 1 IT Programming Introduction

ITP © Ron PoetLecture 1

14

High Level Languages

Almost all programming is done in a high level programming language.

A translation program is run to convert this to a low level language that the computer understands.

This low level language program is then run.

Page 15: ITP © Ron Poet Lecture 1 1 IT Programming Introduction

ITP © Ron PoetLecture 1

15

Compiler

The translation program is called a compiler.

It will check for grammatical errors, called syntax errors.

Eventually, when the program is free of syntax errors, it produces an executable program.This can then be run, or executed.

Page 16: ITP © Ron Poet Lecture 1 1 IT Programming Introduction

ITP © Ron PoetLecture 1

16

Many Computer Languages

The instructions in a low level language must match the electronics on the chip.There is not much room for variation.

The high level language has no such restrictions.Provided a compiler can be written to translate

the instructions into a low level language.Plenty of scope for inventing languages.

Page 17: ITP © Ron Poet Lecture 1 1 IT Programming Introduction

ITP © Ron PoetLecture 1

17

Why Java

All computer languages have advantages and disadvantages.

Java has the advantage that it is wide ranging.Whatever you want to do, there is the Java way

of doing it.Thus there is a consistent way of solving

computer problems.

Page 18: ITP © Ron Poet Lecture 1 1 IT Programming Introduction

ITP © Ron PoetLecture 1

18

Object Oriented

There are many different styles of programming.

Object Oriented is currently the best.Java is object oriented.

Object orientation makes it easier to write large programs.Smaller programs can be more complicated

then they need be.

Page 19: ITP © Ron Poet Lecture 1 1 IT Programming Introduction

ITP © Ron PoetLecture 1

19

Program Development

Running Java programs needs:An editor to create the program.A compiler to produce the executable.A way of integrating libraries.A way of launching the program.

Basic System uses separate toolsA general purpose editor like notepad.General purpose program development tools.

• Make, javac, java.

Page 20: ITP © Ron Poet Lecture 1 1 IT Programming Introduction

ITP © Ron PoetLecture 1

20

Integrated Development Environment

This is a self contained program that provides everything.The editor understands JavaThe compiler can indicate where an error

occurred by marking lines in the editor.Libraries are automatically included.It keeps track of program files.

We will use the IDE eclipse on this course.

Page 21: ITP © Ron Poet Lecture 1 1 IT Programming Introduction

ITP © Ron PoetLecture 1

21

Developing a Program - Syntax

Start by creating the program text in the editor.

Compile the program.This will normally generate syntax errors.Keep editing the program until there are no

more syntax errors.

Page 22: ITP © Ron Poet Lecture 1 1 IT Programming Introduction

ITP © Ron PoetLecture 1

22

Developing a Program - Runtime

Run the program.This will normally generate run time errors.The grammar is correct but program will

eventually try and do something illegal.Keep editing the program until there are no

more runtime errors.

Page 23: ITP © Ron Poet Lecture 1 1 IT Programming Introduction

ITP © Ron PoetLecture 1

23

Developing a Program -Semantic

Test the program.The program may run and appear to work.But the logic is wrong.These logical errors are called semantic errors.

Semantic errors are the hardest to remove.

Page 24: ITP © Ron Poet Lecture 1 1 IT Programming Introduction

ITP © Ron PoetLecture 1

24

Finding Semantic Errors

Work out a number of scenarios.Different ways in which the program can run.

Work out your expected results by hand. Run the program with each scenarios. If the results are different, find out why.

Print out intermediate values to locate the errors.

Develop the program bit by bit, checking as you go.

Page 25: ITP © Ron Poet Lecture 1 1 IT Programming Introduction

ITP © Ron PoetLecture 1

25

In the Lab This Afternoon

Accessing our systemYou will need a user name, which is public.and a password, keep it secret.

The password we give you will not be very memorable.Change it when you have time.

Using emailMost course announcements are by email.

Page 26: ITP © Ron Poet Lecture 1 1 IT Programming Introduction

ITP © Ron PoetLecture 1

26

Try out eclipse

I will give you some programs to type in and see what happens.You are not expected to know a single word of

Java at this stage.

There will be time for discussion during the tutorial at the end of the day.

Page 27: ITP © Ron Poet Lecture 1 1 IT Programming Introduction

ITP © Ron PoetLecture 1

27

Conduct in the Lab

It is good to discuss aspects of the course with other students.

If you want to help a fellow student, teach them how to do things, don't do it for them.

You must do the assessed exercises yourself.