© Peter Andreae What is Programming About COMP 102 #2 2011 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.
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Lecture 1: Overview of Computers & Programming
© Peter Andreae What is Programming About COMP 102 # T1 Peter Andreae Computer Science Victoria University of Wellington.
Slides prepared by Rose Williams, Binghamton University Chapter 1 Getting Started 1.1 Introduction to Java.
Overview of Programming Paradigms
This set of slides is provided by the author of the textbook1 Introductory Topics l Computer Programming l Programming Life-Cycle Phases l Creating an.
The Analytical Engine Module 6 Program Translation.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. COMPSCI 125 Introduction to Computer Science I.
B-1 Lecture 2: Problems, Algorithms, and Programs © 2000 UW CSE University of Washington Computer Programming I.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Introduction to Computers and Programming. Some definitions Algorithm: –A procedure for solving a problem –A sequence of discrete steps that defines such.
Chapter 2: Impact of Machine Architectures What is the Relationship Between Programs, Programming Languages, and Computers.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Course: Introduction to Computers
CS190/295 Programming in Python for Life Sciences: Lecture 1 Instructor: Xiaohui Xie University of California, Irvine.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Java Programs COMP 102 #3.
CS102 Introduction to Computer Programming
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
The Study of Computer Science Chapter 0 Intro to Computer Science CS1510, Section 2.
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)
สาขาวิชาเทคโนโลยี สารสนเทศ คณะเทคโนโลยีสารสนเทศ และการสื่อสาร.
COMPUTER PROGRAMMING Source: Computing Concepts (the I-series) by Haag, Cummings, and Rhea, McGraw-Hill/Irwin, 2002.
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.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming 1.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Programming 1 1. Introduction to object oriented programming and problem-solving.
The Study of Computer Science Chapter 0 Intro to Computer Science CS1510.
COMPUTER PROGRAMS AND LANGUAGES Chapter 4. Developing a computer program Programs are a set (series) of instructions Programmers determine The instructions.
©Xiaoying Gao, Peter Andreae First Java Program COMP 102 #2 2014T2 Xiaoying Sharon Gao Computer Science Victoria University of Wellington.
Media Computing Instructor Byung Kim Olsen 231 Office hours – MWF 9:00-10:00 AM or by appointment.
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.
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.
Chapter 1 Introduction to Computers and C++ Programming Goals: To introduce the fundamental hardware and software components of a computer system To introduce.
Visual C++ Programming: Concepts and Projects
Overview of Programming and Problem Solving Textbook Chapter 1 1.
Computer Programs and Programming Languages What are low-level languages and high-level languages? High-level language Low-level language Machine-dependent.
Chapter 1 Section 1.1 Introduction to Java Slides prepared by Rose Williams, Binghamton University Kenrick Mock, University of Alaska Anchorage.
Robert Crawford, MBA West Middle School.  Explain how the binary system is used by computers.  Describe how software is written and translated  Summarize.
Mrs. Ulshafer August, 2013 Java Programming Chapter 1.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
© Xiaoying Gao, Peter Andreae Introduction to Computer Program Design COMP T2. Xiaoying (Sharon) Gao Computer Science Victoria University of Wellington.
CS 127 Introduction to Computer Science. What is a computer?  “A machine that stores and manipulates information under the control of a changeable program”
© Peter Andreae What is Programming About COMP 102 # T1 Peter Andreae Computer Science Victoria University of Wellington.
1 TOPIC 1 INTRODUCTION TO COMPUTER SCIENCE AND PROGRAMMING Topic 1 Introduction to Computer Science and Programming Notes adapted from Introduction to.
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Java Programs COMP 102 #3.
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
CS 177 Recitation Week 1 – Intro to Java. Questions?
© Peter Andreae Java Programs COMP 102 # T1 Peter Andreae Computer Science Victoria University of Wellington.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
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.
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Course: Introduction to Computers
CS190/295 Programming in Python for Life Sciences: Lecture 1
Computer Programming.
Software Programming J. Holvikivi 2014.
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 Wed/Thu) 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 Plagiarism You must not present anybody else’s work as if it were your own work: Basic principle of academic honesty. Applies to work by other students, friends, relatives, the web, books… If you received substantial help, state who helped and how much. If you declare any work from someone else, then it isn’t plagiarism!!! If in doubt, just declare it and explain it. In COMP102: You can work in pairs on the core parts of assignments BUT You must put a comment at the top of your code saying that you worked with …. If you use code from the assigned text book, or from the lectures, then you do not need to declare it; If you use any other code, then declare it!

© Peter Andreae COMP 102 2:4 Lab Facilities All scheduled labs are in CO 239 and 243 (or VS2.26 at A&D) Can use any of CO 237, 238, 239 and 243 when not booked for a course. Can also use home computers. The number of workstations is limited ⇒ need to be considerate ⇒ cannot guarantee workstations available at just the time you want.

© Peter Andreae COMP 102 2:5 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

© Peter Andreae COMP 102 2:6 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 languages, Specialised languages What is a Program

© Peter Andreae COMP 102 2:7 Machine & Assembly Language What the computer can understand Different for each computer Very detailed, low-level control of the computer Horrible to read : : 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 :

© Peter Andreae COMP 102 2:8 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 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:9 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:10 Programming Languages Different languages support different paradigms: 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:11 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. Supports implementation in Web environment (applets). Extensive libraries of predefined classes to support, UIs, graphics, databases, web applications,... Very portable between kinds of computers.

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

© Peter Andreae COMP 102 2:13 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:14 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:15

© 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 Print out the total / count COMP 102 2:16

© Peter Andreae COMP 102 2:17 A Java Program import comp102.*; /** 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:18 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.

© Peter Andreae COMP 102 2:19 Constructing Programs Initial Design Edit : typing in the Java code Compile : Translating to executable instructions Run : Testing the program to see that it works The Edit—Compile—Run cycle:

© Peter Andreae COMP 102 2:20 What is a Computer? A computer is a machine that manipulates information Words, Sentences, Documents Numbers, Tables, Measurements Instructions, Rules, Procedures Relationships, Concepts, Categories Indexes, Directories, Maps Sounds, Pictures, Shapes Tunes, Stories, Poems Designs Theories

© Peter Andreae COMP 102 2:21 Information: is the stuff of minds, not hands can be created from nothing is not conserved you can copy it you can communicate it you can delete/forget it

© Peter Andreae COMP 102 2:22 Computers are Information Machines Manipulating information requires a different kind of machine from manipulating matter or energy: Represent information. Patterns of bits (on/off, high/low voltage, north/south, light/dark …) [L&L 1.1, appendix B and C] Copy/move information. copy bit patterns from one place to another eg, from main memory to the screen memory Transform information. Construct new bit patterns out of old ones to represent new information

© Peter Andreae COMP 102 2:23 General purpose computers For any single task: Build a Special Purpose Computer. Expensive to design. Expensive to produce unless large market (eg, watches, calculators) Hard to modify! Program a General Purpose Computer to act like a special purpose computer. One physical machine for lots of tasks. Cheap to produce because large market (Relatively) easy to instruct to act as any particular machine. (Relatively) easy to modify if task changes Computers are customisable machines

© Peter Andreae COMP 102 2:24 Computer Structure. Hardware Structure (simplified) (L&L: 1.2) Memory holds data and instructions (programs) Main Memory Central Processing Unit (CPU) Hard Disk USB mem stick CDROM /DVD Keyboard Modem Speakers Mouse/ Tablet Monitor Network (L&L 1.3)