25
Comp1004: Introduction I Welcome!

Comp1004: Introduction I Welcome!. Welcome to Programming Principles Dr. David Millard ([email protected]) Dr. Julian Rathke ([email protected]) Dr

Embed Size (px)

Citation preview

Page 1: Comp1004: Introduction I Welcome!. Welcome to Programming Principles Dr. David Millard (dem@ecs.soton.ac.uk) Dr. Julian Rathke (jr2@ecs.soton.ac.uk) Dr

Comp1004: Introduction I

Welcome!

Page 2: Comp1004: Introduction I Welcome!. Welcome to Programming Principles Dr. David Millard (dem@ecs.soton.ac.uk) Dr. Julian Rathke (jr2@ecs.soton.ac.uk) Dr

Welcome to Programming Principles

Dr. David Millard([email protected])

Dr. Julian Rathke([email protected])

Dr. Mark Weal([email protected])

Additional Seminars:

• Rikki Prince ([email protected])• Patrick McSweeney ([email protected])

Page 3: Comp1004: Introduction I Welcome!. Welcome to Programming Principles Dr. David Millard (dem@ecs.soton.ac.uk) Dr. Julian Rathke (jr2@ecs.soton.ac.uk) Dr

Main Course Structure

• Two Lectures Each Week– Monday 3pm, 02/1089– Tuesday 9am, 02/1089

• Also a Lab (worth 20%)– Monday 9am OR Monday 11am– Depending on Tutor Group

• Other Assessment– Coursework (due weeks 7 and 10, worth 30%)– Open Book Exam (after Xmas, worth 50%)

Page 4: Comp1004: Introduction I Welcome!. Welcome to Programming Principles Dr. David Millard (dem@ecs.soton.ac.uk) Dr. Julian Rathke (jr2@ecs.soton.ac.uk) Dr

Additional Streams

• Space Cadets– For people who are more experienced programmers– Run by Rikki Prince– Optional weekly challenge and discussion

• Ground Controllers– For people who are new to programming– Run by Patrick McSweeney– Optional weekly workshop

Page 5: Comp1004: Introduction I Welcome!. Welcome to Programming Principles Dr. David Millard (dem@ecs.soton.ac.uk) Dr. Julian Rathke (jr2@ecs.soton.ac.uk) Dr

BlueJ• The main course text is

Objects First with BlueJ

• Although we will start with using Java from the command line, we will soon introduce you to the BlueJ environment

• BlueJ is an environment designed for learning, but later in the course we will change over to use a proper professional environment

Page 6: Comp1004: Introduction I Welcome!. Welcome to Programming Principles Dr. David Millard (dem@ecs.soton.ac.uk) Dr. Julian Rathke (jr2@ecs.soton.ac.uk) Dr

A Dirty Secret

• No matter how we teach you will mainly learn through practice!

• Programming is the single most important skill for a computer scientist or software engineer– Systematic thinking and problem solving– Abstraction and data modeling

• Did we mention that you need to practice?

Page 7: Comp1004: Introduction I Welcome!. Welcome to Programming Principles Dr. David Millard (dem@ecs.soton.ac.uk) Dr. Julian Rathke (jr2@ecs.soton.ac.uk) Dr

PRACTICE!“I've often thought that sucking less every year is how humble programmers improve. You should be unhappy with code you wrote a year ago.”

- Jeff Atwood, http://www.codinghorror.com/

“I have no talent. What I do have is a lot of practice. And I am not talking about occasionally dabbling in Ruby on the weekends. I am talking about the kind of practice where I beat code that isn’t working into submission (though often times the code wins).”

- John Nunemaker, http://railstips.org/

Page 8: Comp1004: Introduction I Welcome!. Welcome to Programming Principles Dr. David Millard (dem@ecs.soton.ac.uk) Dr. Julian Rathke (jr2@ecs.soton.ac.uk) Dr

Online Notes Wiki

https://secure.ecs.soton.ac.uk/

notes/comp1004/

leads to

https://secure.ecs.soton.ac.uk/

student/wiki/w/COMP1004

Page 9: Comp1004: Introduction I Welcome!. Welcome to Programming Principles Dr. David Millard (dem@ecs.soton.ac.uk) Dr. Julian Rathke (jr2@ecs.soton.ac.uk) Dr

Comp1004: Introduction II

Starting Out

Page 10: Comp1004: Introduction I Welcome!. Welcome to Programming Principles Dr. David Millard (dem@ecs.soton.ac.uk) Dr. Julian Rathke (jr2@ecs.soton.ac.uk) Dr

In this lecture

• What is Programming?• Programming Paradigms

• A Taste of Things to Come– Classes and Objects– Variables– Logic– Data Structures

Page 11: Comp1004: Introduction I Welcome!. Welcome to Programming Principles Dr. David Millard (dem@ecs.soton.ac.uk) Dr. Julian Rathke (jr2@ecs.soton.ac.uk) Dr

What is Programming?

Page 12: Comp1004: Introduction I Welcome!. Welcome to Programming Principles Dr. David Millard (dem@ecs.soton.ac.uk) Dr. Julian Rathke (jr2@ecs.soton.ac.uk) Dr

What is Programming?

• Wikipedia (2011)– “the process of writing, testing, debugging and maintaining the

source code of computer programs. The purpose of programming is to create a program that exhibits a certain desired behavior.”

• Thefreedictionary.com (2011)– “creating a sequence of instructions to enable the computer to do

something”

• OED (2011)– “The operation or practice of programming a computer; the

writing or preparation of computer programs.”

Page 13: Comp1004: Introduction I Welcome!. Welcome to Programming Principles Dr. David Millard (dem@ecs.soton.ac.uk) Dr. Julian Rathke (jr2@ecs.soton.ac.uk) Dr

What is Programming?

• Wikipedia (2011)– “the process of writing, testing, debugging and maintaining the

source code of computer programs. The purpose of programming is to create a program that exhibits a certain desired behavior.”

• Thefreedictionary.com (2011)– “creating a sequence of instructions to enable the computer to do

something”

• OED (2011)– “The operation or practice of programming a computer; the

writing or preparation of computer programs.”

Page 14: Comp1004: Introduction I Welcome!. Welcome to Programming Principles Dr. David Millard (dem@ecs.soton.ac.uk) Dr. Julian Rathke (jr2@ecs.soton.ac.uk) Dr

What is Programming?

• Wikipedia (2011)– “the process of writing, testing, debugging and maintaining the

source code of computer programs. The purpose of programming is to create a program that exhibits a certain desired behavior.”

• Thefreedictionary.com (2011)– “creating a sequence of instructions to enable the computer to do

something”

• OED (2011)– “The operation or practice of programming a computer; the

writing or preparation of computer programs.”

Page 15: Comp1004: Introduction I Welcome!. Welcome to Programming Principles Dr. David Millard (dem@ecs.soton.ac.uk) Dr. Julian Rathke (jr2@ecs.soton.ac.uk) Dr

What is Programming?

• Wikipedia (2011)– “the process of writing, testing, debugging and maintaining the

source code of computer programs. The purpose of programming is to create a program that exhibits a certain desired behavior.”

• Thefreedictionary.com (2011)– “creating a sequence of instructions to enable the computer to do

something”

• OED (2011)– “The operation or practice of programming a computer; the

writing or preparation of computer programs.”

Page 16: Comp1004: Introduction I Welcome!. Welcome to Programming Principles Dr. David Millard (dem@ecs.soton.ac.uk) Dr. Julian Rathke (jr2@ecs.soton.ac.uk) Dr

Programming Flavours

• Procedural (e.g. C or Pascal)– Fixed list of instructions– Do this, Do that, if this then do that

• Declarative – More like declaring rules (or a grammar)– Behaviour emerges from the rules being applied– Examples

• Functional Programming (e.g. Scheme)• Logic Programming (e.g. Prolog)

Page 17: Comp1004: Introduction I Welcome!. Welcome to Programming Principles Dr. David Millard (dem@ecs.soton.ac.uk) Dr. Julian Rathke (jr2@ecs.soton.ac.uk) Dr

Object Orientated

The main idea– Everything is a Thing– A Program is made up of Things interacting

– Things have both properties and behaviours– E.g. Dog

•What are the properties of a dog?•What can a dog do?

Page 18: Comp1004: Introduction I Welcome!. Welcome to Programming Principles Dr. David Millard (dem@ecs.soton.ac.uk) Dr. Julian Rathke (jr2@ecs.soton.ac.uk) Dr

Classes and ObjectsAll the properties of Dog can be wrapped up or contained in a class

– A class is like a Blue Print– We can build many unique dogs from the same Blue Print– These are called objects– They all have similar properties as defined by the class

http://www.animalblueprintcompany.com/

1 Class 101 Objects

Page 19: Comp1004: Introduction I Welcome!. Welcome to Programming Principles Dr. David Millard (dem@ecs.soton.ac.uk) Dr. Julian Rathke (jr2@ecs.soton.ac.uk) Dr

Building Blocks

• Objects and Classes are specific to Object Orientated Programming

• But there are more common, more fundamental Programming Principles that we will be covering in the course

Page 20: Comp1004: Introduction I Welcome!. Welcome to Programming Principles Dr. David Millard (dem@ecs.soton.ac.uk) Dr. Julian Rathke (jr2@ecs.soton.ac.uk) Dr

Variables

• Like algebrax = 4

• Not so much like algebraname = “Rover”

• Object properties are stored in variables

Page 21: Comp1004: Introduction I Welcome!. Welcome to Programming Principles Dr. David Millard (dem@ecs.soton.ac.uk) Dr. Julian Rathke (jr2@ecs.soton.ac.uk) Dr

Methods

• Blocks of code that define a sequence of actions• Object behavior is defined in methods• Often this will use the object’s properties

printDogsDetails(){print name;print age;

}

Page 22: Comp1004: Introduction I Welcome!. Welcome to Programming Principles Dr. David Millard (dem@ecs.soton.ac.uk) Dr. Julian Rathke (jr2@ecs.soton.ac.uk) Dr

Logic

True or False – the basis of all decisions

?

x == 4

x > 4

x =< 4

x != 4

x > 2 && x < 8

x > 8 || x < 2

x = 3

false

false

true

true

true

false

x=4

true

false

true

false

true

false

x=11

false

true

false

true

false

true

Page 23: Comp1004: Introduction I Welcome!. Welcome to Programming Principles Dr. David Millard (dem@ecs.soton.ac.uk) Dr. Julian Rathke (jr2@ecs.soton.ac.uk) Dr

Control Flow• If statements

if size<10dog says “Yip Yip”

elsedog says “Ruff Ruff”

• Loops

while(number<10)dog says “Bark!”number= number +1

Side Note:

Human readable versions of programs are called Pseudocode.

They look like real programs but are not as precisely defined.

They are good for communicating ideas and showing structure.

Page 24: Comp1004: Introduction I Welcome!. Welcome to Programming Principles Dr. David Millard (dem@ecs.soton.ac.uk) Dr. Julian Rathke (jr2@ecs.soton.ac.uk) Dr

Data Structures

• More complex data…

• Arrays:– Like Lists, Tables, Matrices

• HashMaps– Associate a key with a value– Like a Dictionary

Page 25: Comp1004: Introduction I Welcome!. Welcome to Programming Principles Dr. David Millard (dem@ecs.soton.ac.uk) Dr. Julian Rathke (jr2@ecs.soton.ac.uk) Dr

Summary

• What is Programming?• Programming Paradigms

• A Taste of Things to Come– Classes and Objects– Variables– Logic– Data Structures