© Peter Andreae What is Programming About COMP 102 #2 2015 T1 Peter Andreae Computer Science Victoria University of Wellington.

Slides:



Advertisements
Similar presentations
Senem Kumova Metin Introduction to Programming CS 115 Introduction to Computing PART I : Computer Basics PART II: Introduction to Computing/Programming.
Advertisements

©Xiaoying Gao, Peter Andreae What is Programming About COMP 102 #2 2013T2 Xiaoying Sharon Gao Computer Science Victoria University of Wellington.
Lecture 1: Overview of Computers & Programming
Computers Are Your Future
Programming Types of Testing.
Overview of Programming Paradigms
The Analytical Engine Module 6 Program Translation.
B-1 Lecture 2: Problems, Algorithms, and Programs © 2000 UW CSE University of Washington Computer Programming I.
1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming.
Aalborg Media Lab 21-Jun-15 Software Design Lecture 1 “ Introduction to Java and OOP”
Programming Introduction November 9 Unit 7. What is Programming? Besides being a huge industry? Programming is the process used to write computer programs.
Summer 02-03Programming Language Concepts1 Programming Language Concepts (CS 360) Lecture 1: Overview, Grammars, and Little Languages Jeremy R. Johnson.
1 CS101 Introduction to Computing Lecture 19 Programming Languages.
Introduction to Programming (in C++) Introduction Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC.
CS190/295 Programming in Python for Life Sciences: Lecture 1 Instructor: Xiaohui Xie University of California, Irvine.
Announcements — Tues., Jan. 19 For next time, read Learning Computing with Robots, chs. 1 and 2. The Blackboard site is up and operational! not much content.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Java Programs COMP 102 #3.
1 Chapter-01 Introduction to Computers and C++ Programming.
Introduction COMP104: Fundamentals and Methodology.
There are only 10 types of people in the world, those who understand binary and those who don't.
Chapter 8 High-Level Programming Languages (modified by Erin Chambers)
(1.1) COEN 171 Programming Languages Winter 2000 Ron Danielson.
สาขาวิชาเทคโนโลยี สารสนเทศ คณะเทคโนโลยีสารสนเทศ และการสื่อสาร.
COMPUTER PROGRAMMING Source: Computing Concepts (the I-series) by Haag, Cummings, and Rhea, McGraw-Hill/Irwin, 2002.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Summary and Exam COMP 102.
An intro to programming. The purpose of writing a program is to solve a problem or take advantage of an opportunity Consists of multiple steps:  Understanding.
CS 7: Introduction to Computer Programming Algorithms.
Programming 1 1. Introduction to object oriented programming and problem-solving.
COMPUTER PROGRAMS AND LANGUAGES Chapter 4. Developing a computer program Programs are a set (series) of instructions Programmers determine The instructions.
Introduction to Computers and Programming – Computer Programming.
CS161 Topic #21 CS161 Introduction to Computer Science Topic #2.
©Xiaoying Gao, Peter Andreae First Java Program COMP 102 #2 2014T2 Xiaoying Sharon Gao Computer Science Victoria University of Wellington.
Chapter 1 What is Programming? Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E.
CS101 Introduction to Computing Lecture Programming Languages.
First Java Program COMP 102 #2 2015T2 Xiaoying Sharon Gao Computer Science Victoria University of Wellington.
© Xiaoying Gao, Peter Andreae Introduction to Computer Program Design COMP T2. Xiaoying (Sharon) Gao Computer Science Victoria University of Wellington.
TMF1013 : Introduction To Computing Lecture 1 : Fundamental of Computer ComputerFoudamentals.
© Peter Andreae What is Programming About COMP 102 # T1 Peter Andreae Computer Science Victoria University of Wellington.
1 Programming Language History and Evolution In Text: Chapter 2.
Visual C++ Programming: Concepts and Projects
Computer Programs and Programming Languages What are low-level languages and high-level languages? High-level language Low-level language Machine-dependent.
IXA 1234 : C++ PROGRAMMING CHAPTER 1. PROGRAMMING LANGUAGE Programming language is a computer program that can solve certain problem / task Keyword: Computer.
© Xiaoying Gao, Peter Andreae Introduction to Computer Program Design COMP T2. Xiaoying (Sharon) Gao Computer Science Victoria University of Wellington.
© Peter Andreae What is Programming About COMP 102 # T1 Peter Andreae Computer Science Victoria University of Wellington.
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 1 Overview A good programming language is.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Java Programs COMP 102 #3.
Some Computer Science Conceptual Background Material Doug Hogan This version for UIC Spring 2016 CS 107.
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
© Peter Andreae Java Programs COMP 102 # T1 Peter Andreae Computer Science Victoria University of Wellington.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Software Engineering Algorithms, Compilers, & Lifecycle.
Victoria Ibarra Mat:  Generally, Computer hardware is divided into four main functional areas. These are:  Input devices Input devices  Output.
Programming Language History and Evolution
Programming Languages 2nd edition Tucker and Noonan
Introduction to programming languages, Algorithms & flowcharts
Topic: Programming Languages and their Evolution + Intro to Scratch
Introduction to programming languages, Algorithms & flowcharts
Problem Solving Using C: Orientation & Lecture 1
CS101 Introduction to Computing Lecture 19 Programming Languages
Programming Language History and Evolution
Introduction to programming languages, Algorithms & flowcharts
Software Programming J. Holvikivi 2014.
Problem Solving.
Programming Language Design
Principles of Programming Languages
Lecture 8 Programming Paradigm & Languages. Programming Languages The process of telling the computer what to do Also known as coding.
Presentation transcript:

© Peter Andreae What is Programming About COMP 102 # T1 Peter Andreae Computer Science Victoria University of Wellington

© Peter Andreae COMP 102 2:2 Menu More course details Strategies for learning in COMP102. Programs and programming languages Object Oriented Programming Reading: Text Book Chapter 1 Announcements: Sign up for a lab session! (Labs start Today) Voting for a Class Rep Put a message about yourself on the forum if you want to be class representative; the class will vote on Monday. Trouble with passwords? Go to school office: CO 358

© Peter Andreae COMP 102 2:3 Lectures vs Textbook Lectures Interactive Multiple media Real time Good for Overview Motivation Problem solving methods Understanding Illustration Textbook One way Visual only Static Re-readable Carefully checked and edited Good for Detailed explanations Lists of facts and rules Careful definitions Large examples How do you use lectures effectively? You didn’t have lectures at school!!

© Peter Andreae COMP 102 2:4 A program is a specification for the behaviour of a computer: What the computer should do when: the program is started the user types something the user clicks with the mouse a message arrives over the network some input from a camera/switch/sensor arrives. …… Responses may be simple or very complex. A program consists of descriptions of responses to events/requests written as instructions in a language the computer can understand: Low level, High level, Specialised What is a Program

© Peter Andreae COMP 102 2:5 Machine & Assembly Language What the computer can understand Different for each computer Very detailed, low-level control of the computer Horrible to read : 000XX00X 0X00XXXX 0XX0X00X 00XXX0X0 00X0X00X X0XX0X0X : copy the contents of memory location 143 into register 1. add the contents of memory location 116 to the contents of register 1. copy the contents of register 1 to memory location 181. : LD d1 143 AD d1 116 ST d1 181 : Pattern of bits controls the switches that operate the CPU

© Peter Andreae COMP 102 2:6 High Level Programming Languages Designed for people to use Designed to be translated into machine language compiled (translated all at once), or interpreted (translated one step at a time), or compiled to an intermediate language, then interpreted (examples at: ) Must be Precise: no ambiguity about what to do Expressive:must be able to specify whatever you want done. Readable: People must be able to read the instructions. Translatable:able to be translated into machine language Concise: not “long-winded” or redundant Smalltalk ML Ada C++ Eiffel Prolog Haskell Miranda Java C# Python Scratch GameMaker Alice FORTRAN LISP Algol COBOL Basic C Pascal Simula Modula PHP Javascript

© Peter Andreae COMP 102 2:7 Specialised language: MazeMouse Writing a program to control a Mouse in a Maze The mouse should get out of the maze No matter what shape the maze is!! The program must cope with “the general case”! Very simple language: Sequence of Forward, Left, and/or Right eg: FLFR What should the mouse do when there’s a space ahead there’s a space only to the left there’s a space only to the right there’s space only to the sides it’s in a dead-end ??

© Peter Andreae COMP 102 2:8 Programming Languages Different languages support different “paradigms”: (ways of designing) imperative, object-oriented, functional, logic programming,... Object Oriented programming languages: Organise program around Classes (types) of objects Each class of objects can perform a particular set of actions Most instructions consist of asking an object to perform one of its actions

© Peter Andreae COMP 102 2:9 Java A high-level Object-Oriented programming language Designed by Sun Microsystems, early-mid 1990's. Widely used in teaching and industry. Related to C++, but simpler. Similar to C#. Good for interactive applications. Extensive libraries of predefined classes to support, UIs, graphics, databases, web applications,... Very portable between kinds of computers.

© Peter Andreae COMP 102 2:10 Constructing Programs Design Edit Test The Design—Edit—Test cycle: Given a task:

© Peter Andreae COMP 102 2:11 Building programs Specification: Work out what you want the program to accomplish Design Work out what the computer must do to accomplish the task Edit Express the design in a programming language instructions for individual steps, structure of the program Test Run the program and see whether it works as intended may need to try it out on lots of different cases.

© Peter Andreae COMP 102 2:12 A program for the Maze Mouse Specification Program to get the mouse out of any maze with a reachable exit (Mouse always starts in the top left corner facing right) Design "make the mouse move into an empty space, When there is a choice, go forward if possible, otherwise to the left" Edit space ahead space only to the left space only to the right space only to the sides dead-end ?? F LF RF LF LLF Program

© Peter Andreae Testing the program (Try it out with the MazeMouse demo) COMP 102 2:13

© Peter Andreae A different task: Specification: Find the average of a sequence of numbers from the user Design: Initialise a count and a running total to 0 Ask the user to enter the numbers Repeat until there are no more numbers: read the next number add it to the total increase the count by 1 If there was at least one number Print out the total / count Otherwise, print a message. COMP 102 2:14

© Peter Andreae COMP 102 2:15 A Java Program import ecs100.*; /** Program to compute the average of a sequence of numbers */ public class MeanFinder { public void findMean () { double total= 0; int count =0; UI.print( "Enter numbers (followed by 'done'): " ); while ( UI.hasNextDouble( ) ) { total = total + UI.nextDouble( ); count = count + 1; } if (count > 0) { UI.printf( "Mean = %5.2f \n", (total/count) ); } else { UI.println( "You entered no numbers"); }

© Peter Andreae COMP 102 2:16 Learning to Program in Java What’s involved? Understand what the computer can do and what the language can specify Problem solving: program design, data structuring, Programming language (Java): syntax and semantics style and common patterns libraries of code written by other people Testing and Debugging (fixing). Common patterns in program design. Important data structures and algorithms.