Chapter 1: Introduction to Computers and Java

Slides:



Advertisements
Similar presentations
Designing a Program & the Java Programming Language
Advertisements

CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
Lecture 0 CSIS10A Overview. Welcome to CSIS10A (5 mins) – Typical format for class meetings New material first (monitors off, notebooks out) Practice.
16/13/2015 3:30 AM6/13/2015 3:30 AM6/13/2015 3:30 AMIntroduction to Software Development What is a computer? A computer system contains: Central Processing.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design First Edition by Tony Gaddis.
1 Fall 2008ACS-1903 Chapter 1 Topics Java History Java Programs Why Program? Computer Systems: Hardware and Software Programming Languages What Is a Program.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
COMP 14: Intro. to Intro. to Programming May 23, 2000 Nick Vallidis.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
CS190/295 Programming in Python for Life Sciences: Lecture 1 Instructor: Xiaohui Xie University of California, Irvine.
CS102 Introduction to Computer Programming
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Chapter Introduction to Computers and Programming 1.
CHAPTER 4: INTRODUCTION TO COMPUTER ORGANIZATION AND PROGRAMMING DESIGN Lec. Ghader Kurdi.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
Introducing Java.
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.
CS 106 Introduction to Computer Science I 01 / 25 / 2010 Instructor: Michael Eckmann.
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.
Java Programming, Second Edition Chapter One Creating Your First Java Program.
Week 1 - Friday.  What did we talk about last time?  Our first Java program.
CS 127 Introduction to Computer Science. What is a computer?  “A machine that stores and manipulates information under the control of a changeable program”
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
Chapter 1 Introduction. Chapter Goals To understand the activity of programming To learn about the architecture of computers To learn about machine code.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. CSC 110 – INTRO TO COMPUTING - PROGRAMMING Overview of Programming.
Brief Version of Starting Out with C++ Chapter 1 Introduction to Computers and Programming.
CS 177 Recitation Week 1 – Intro to Java. Questions?
CHAPTER 1 Introduction to Computers and Java Copyright © 2016 Pearson Education, Ltd.
Chapter 1: Introduction to Computers and Programming.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Introduction to Object Oriented
Chapter 1: Introduction to Computers and Programming
Chapter 1 Introduction 2nd Semester H
Java Programming: From the Ground Up
BASIC PROGRAMMING C SCP1103 (02)
Lecture 1b- Introduction
Development Environment
Visit for more Learning Resources
Key Ideas from day 1 slides
Lecture 1: Introduction to JAVA
BASIC PROGRAMMING C SCP1103 (02)
Console Output, Variables, Literals, and Introduction to Type
DDC 1023 – Programming Technique
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Chapter 1: Introduction to Computers and Java
Java programming lecture one
Computer science By/ Midhat Mohiey. Introduction to Programming using C ++ 2.
Introduction to Java Dept. Business Computing University of Winnipeg
Chapter 1: Introduction to Computers and Programming
CS190/295 Programming in Python for Life Sciences: Lecture 1
Introduction CSC 111.
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
Chapter 1 Introduction(1.1)
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
15-110: Principles of Computing
Welcome to AP Computer Science A!
Welcome to AP Computer Science A!
Tonga Institute of Higher Education IT 141: Information Systems
Tonga Institute of Higher Education IT 141: Information Systems
Computer Programming-1 CSC 111
ICS103 Programming in C 1: Overview of Computers And Programming
IS 135 Business Programming
Programming Logic and Design Eighth Edition
Chapter 1: Introduction to Computers and Programming
Presentation transcript:

Chapter 1: Introduction to Computers and Java

Agenda Introductions Course Administration PB sandwich demo Computer Hardware Machine language and compiled languages The Java Virtual Machine Common features of programming languages Variables and Algorithms Java “Hello World” Demo Programming paradigms

Welcome to CSIS10A (5 mins) Typical format for class meetings Lectures on Tuesday (monitors off, notebooks out) Do Pre-Lab before Thursday Thursday Lab, practice new material Syllabus Aim of this course (learning Java) What is a program? A set of step-by-step instructions that directs a computer to solve some problem. Pretty much anything you can do with a computer, you can do by programming in Java

Do introductions (15 mins) class website: http://tomrebold.com/csis10a Passcode for website: Click at bottom on CSIS10A Guest Book Name Major and what year Why taking the course Something unique about yourself then we go around and tell each other

Do administrative stuff (10 mins) Few if any handouts will be printed. They will be posted on the web instead. No late work (model solutions, quick turnaround) For conflicts with class meetings: let me know now! We will use the textbook Starting Out with Java by Gaddis (4th or 5th edition OK) A word about Academic Honesty How to get help Computer science tutor will be available – Steve Bruemmer our instructional tech, 9-5 most days

Warning – there is MATH in this class!! If you didn’t like math (algebra), you probably will have a hard time in this class Solve for x: 5x + 3 = 13 What is 8 squared? Square root of 36 Area of a circle of radius 2: Average of 10, 14, 8, 4 Convert 3 kg into lbs Convert 43 ounces into pounds and ounces What is 15% of $30.00 ?

The Wise Approach If the class seems too hard for you enroll in the advisory courses first like MATH263, ENGL111/112, CSIS1 then come back to CSIS10A A solid foundation in English and Math will prepare you for much of what you will discover at MPC and beyond! Java has a number of advanced concepts CSIS1 provides a gentler programming intro

Do PB & J demonstration (20 mins) Get into groups of 3 and write up instructions (10 mins) Present the results and have me follow those directions (10 mins)

PBJ Debrief Talk about observations; similarities to programming Explicitness Sequence, selection, repetition Dependencies - when does order matter? Closing open files and stuff What is a basic command? Unexpected uses of software Infinite loops

Course will be challenging, fun, painful at times - much like making a sandwich But, you will make yourself more marketable or may get sold on computer science!

Basic computer anatomy

What the parts do CPU Storage Input devices (the ``I'' in ``I/O'') ``The brain''; performs relatively basic operations It only executes machine language The machine language varies from CPU to CPU Storage Primary storage/random-access memory/RAM/``memory'' Fast, but volatile and expensive Secondary storage/hard drive/hard disk Cheap and non-volatile, but slow Input devices (the ``I'' in ``I/O'') Mouse, keyboard Output devices (the ``O'' in ``I/O'') Monitor, speakers, printer

How hardware relates to programming Your .java program files are files, therefore found on the hard drive (typically) Programs need to run fast, so the computer uses primary memory for programs that are currently running. There are ways to communicate with I/O devices in Java.

Communicating instructions to the computer Problem: We want to give instructions to the CPU, but the CPU's language is hard for humans to read, write, and understand. How do we handle this? One (painful) solution: Just program in machine code Why is this so painful? Just note this C code: main() { printf("hello, world"); } does the same thing as the machine code on the next slide. Since machine code depends on the CPU, the program would only work on a limited number of machines anyway

"Hello World" program in machine code 127 69 76 70 1 1 1 0 0 0 0 0 0 0 0 0 2 0 3 0 1 0 0 0 224 130 4 8 52 0 0 0 88 7 0 0 0 0 0 0 52 0 32 0 7 0 40 0 28 0 25 0 6 0 0 0 52 0 0 0 52 128 4 8 52 128 4 8 224 0 0 0 224 0 0 0 5 0 0 0 4 0 0 0 3 0 0 0 20 1 0 0 20 129 4 8 20 129 4 8 19 0 0 0 19 0 0 0 4 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 128 4 8 0 128 4 8 188 4 0 0 188 4 0 0 5 0 0 0 0 16 0 0 1 0 0 0 188 4 0 0 188 148 4 8 188 148 4 8 8 1 0 0 12 1 0 0 6 0 0 0 0 16 0 0 2 0 0 0 208 4 0 0 208 148 4 8 208 148 4 8 208 0 0 0 208 0 0 0 6 0 0 0 4 0 0 0 4 0 0 0 40 1 0 0 40 129 4 8 40 129 4 8 32 0 0 0 32 0 0 0 4 0 0 0 4 0 0 0 81 229 116 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 0 0 0 4 0 0 0 47 108 105 98 47 108 100 45 108 105 110 117 120 46 115 111 46 50 0 0 4 0 0 0 16 0 0 0 1 0 0 0 71 78 85 0 0 0 0 0 2 0 0 0 2 0 0 0 5 0 0 0 3 0 0 0 6 0 0 0 5 0 0 0 1 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 68 0 0 0 0 0 0 0 221 0 0 0 18 0 0 0 46 0 0 0 0 0 0 0 54 0 0 0 18 0 0 0 53 0 0 0 164 132 4 8 4 0 0 0 17 0 14 0 1 0 0 0 0 0 0 0 0 0 0 0 32 0 0 0 21 0 0 0 0 0 0 0 0 0 0 0 32 0 0 0 0 95 74 118 95 82 101 103 105 115 116 101 114 67 108 97 115 115 101 115 0 95 95 103 109 111 110 95 115 116 97 114 116 95 95 0 108 105 98 99 46 115 111 46 54 0 112 114 105 110 116 102 0 95 73 79 95 115 116 100 105 110 95 117 115 101 100 0 95 95 108 105 98 99 95 115 116 97 114 116 95 109 97 105 110 0 47 115 47 103 99 99 45 51 46 52 46 52 47 105 51 56 54 95 99 101 110 116 52 48 47 108 105 98 0 71 76 73 66 67 95 50 46 48 0 0 0 0 2 0 2 0 1 0 0 0 0 0 0 0 1 0 1 0 36 0 0 0 16 0 0 0 0 0 0 0 16 105 105 13 0 0 2 0 115 0 0 0 0 0 0 0 160 149 4 8 6 5 0 0 176 149 4 8 7 1 0 0 180 149 4 8 7 2 0 0 85 137 229 131 236 8 232 97 0 0 0 232 184 0 0 0 232 179 1 0 0 201 195 0 255 53 168 149 4 8 255 37 172 149 4 8 0 0 0 0 255 37 176 149 4 8 104 0 0 0 0 233 224 255 255 255 255 37 180 149 4 8 104 8 0 0 0 233 208 255 255 255 49 237 94 137 225 131 228 240 80 84 82 104 20 132 4 8 104 192 131 4 8 81 86 104 148 131 4 8 232 191 255 255 255 244 144 144 85 137 229 83 232 0 0 0 0 91 129 195 151 18 0 0 82 139 131 252 255 255 255 133 192 116 2 255 208 88 91 201 195 144 144 144 144 144 144 144 144 144 144 144 85 137 229 131 236 8 128 61 196 149 4 8 0 116 12 235 28 131 192 4 163 192 149 4 8 255 210 161 192 149 4 8 139 16 133 210 117 235 198 5 196 149 4 8 1 201 195 144 85 137 229 131 236 8 161 204 148 4 8 133 192 116 33 184 0 0 0 0 133 192 116 24 199 4 36 204 148 4 8 232 124 124 251 247 141 182 0 0 0 0 141 191 0 0 0 0 201 195 144 144 85 137 229 131 236 8 131 228 240 184 0 0 0 0 131 192 15 131 192 15 193 232 4 193 224 4 41 196 199 4 36 168 132 4 8 232 20 255 255 255 201 195 144 144 85 137 229 87 86 83 131 236 12 232 0 0 0 0 91 129 195 214 17 0 0 232 190 254 255 255 141 131 24 255 255 255 141 147 24 255 255 255 137 69 240 41 208 49 246 193 248 2 57 198 115 22 137 215 137 246 255 20 178 139 77 240 41 249 70 193 249 2 57 206 137 250 114 238 131 196 12 91 94 95 201 195 137 246 85 137 229 87 86 83 232 0 0 0 0 91 129 195 133 17 0 0 141 131 24 255 255 255 141 187 24 255 255 255 41 248 193 248 2 131 236 12 141 112 255 235 5 144 255 20 183 78 131 254 255 117 247 232 54 0 0 0 131 196 12 91 94 95 201 195 144 144 144 144 144 144 144 144 144 144 85 137 229 83 131 236 4 187 188 148 4 8 161 188 148 4 8 235 7 131 235 4 255 208 139 3 131 248 255 117 244 88 91 93 195 144 85 137 229 83 232 0 0 0 0 91 129 195 23 17 0 0 80 232 150 254 255 255 89 91 201 195 0 0 3 0 0 0 1 0 2 0 104 101 108 108 111 44 32 119 111 114 108 100 0 0 0 0 0 0 0 0 255 255 255 255 0 0 0 0 255 255 255 255 0 0 0 0 0 0 0 0 1 0 0 0 36 0 0 0 15 0 0 0 86 0 0 0 12 0 0 0 152 130 4 8 13 0 0 0 132 132 4 8 4 0 0 0 72 129 4 8 5 0 0 0 212 129 4 8 6 0 0 0 116 129 4 8 10 0 0 0 125 0 0 0 11 0 0 0 16 0 0 0 21 0 0 0 0 0 0 0 3 0 0 0 164 149 4 8 2 0 0 0 16 0 0 0 20 0 0 0 17 0 0 0 23 0 0 0 136 130 4 8 17 0 0 0 128 130 4 8 18 0 0 0 8 0 0 0 19 0 0 0 8 0 0 0 254 255 255 111 96 130 4 8 255 255 255 111 1 0 0 0 240 255 255 111 82 130 4 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 208 148 4 8 0 0 0 0 0 0 0 0 198 130 4 8 214 130 4 8 0 0 0 0 0 0 0 0 200 148 4 8 0 71 67 67 58 32 40 71 78 85 41 32 51 46 52 46 54 32 50 48 48 54 48 52 48 52 32 40 82 101 100 32 72 97 116 32 51 46 52 46 54 45 56 41 0 0 71 67 67 58 32 40 71 78 85 41 32 51 46 52 46 54 32 50 48 48 54 48 52 48 52 32 40 82 101 100 32 72 97 116 32 51 46 52 46 54 45 56 41 0 0 71 67 67 58 32 40 71 78 85 41 32 51 46 52 46 52 0 0 71 67 67 58 32 40 71 78 85 41 32 51 46 52 46 52 0 0 71 67 67 58 32 40 71 78 85 41 32 51 46 52 46 52 0 0 71 67 67

One (bad) solution: Try to make a system where we can just type in instructions with natural language, and have the computer translate that into machine code. Extremely difficult Very ambiguous; for example, in "I called the guy with the cell phone'' - who is carrying the cell phone?

One (better) solution: Use an intermediate language that is somewhat easy for humans to use (i.e. Pascal, C++, etc.), and have the computer translate that into machine code. This translator is called a compiler. Compiled languages such as C work in this way.

Running programs the Java way In Java, the computer simulates an imaginary CPU with very particular specifications. This imaginary CPU is called the Java virtual machine (or JVM). Java simulates the JVM much like an emulator simulates a Super-Nintendo Main advantage: The same code can be made to run on any machine without modification (see previous slide). Example: Good for Java applets on the web

Running programs the Java way Another advantage: Much better security can be implemented when running code in a virtual machine. Example: again, crucial for Java applets on the web One disadvantage: Simulating the JVM makes the program run slower One caveat: There can actually be variations in your program from machine to machine, for a number of reasons Different I/O devices Different library implementations (or bugs) Bugs in a JVM implementation (yes, it happens)

Source file  compiler  bytecode The JVM's language is bytecode, which is found inside .class files. The compiler converts java files into class files Class files are not human readable See the bytecode for the HelloWorld.java program

Java source file public class HelloWorld {     public static void main(String[] args) {         System.out.println("Hello, World!");     } }

Java Bytecode for previous slide 202 254 186 190 0 0 0 49 0 34 1 0 10 72 101 108 108 111 87 111 114 108 100 7 0 1 1 0 16 106 97 118 97 47 108 97 110 103 47 79 98 106 101 99 116 7 0 3 1 0 6 60 105 110 105 116 62 1 0 3 40 41 86 1 0 4 67 111 100 101 12 0 5 0 6 10 0 4 0 8 1 0 15 76 105 110 101 78 117 109 98 101 114 84 97 98 108 101 1 0 18 76 111 99 97 108 86 97 114 105 97 98 108 101 84 97 98 108 101 1 0 4 116 104 105 115 1 0 12 76 72 101 108 108 111 87 111 114 108 100 59 1 0 4 109 97 105 110 1 0 22 40 91 76 106 97 118 97 47 108 97 110 103 47 83 116 114 105 110 103 59 41 86 1 0 16 106 97 118 97 47 108 97 110 103 47 83 121 115 116 101 109 7 0 16 1 0 3 111 117 116 1 0 21 76 106 97 118 97 47 105 111 47 80 114 105 110 116 83 116 114 101 97 109 59 12 0 18 0 19 9 0 17 0 20 1 0 13 72 101 108 108 111 44 32 87 111 114 108 100 33 8 0 22 1 0 19 106 97 118 97 47 105 111 47 80 114 105 110 116 83 116 114 101 97 109 7 0 24 1 0 7 112 114 105 110 116 108 110 1 0 21 40 76 106 97 118 97 47 108 97 110 103 47 83 116 114 105 110 103 59 41 86 12 0 26 0 27 10 0 25 0 28 1 0 4 97 114 103 115 1 0 19 91 76 106 97 118 97 47 108 97 110 103 47 83 116 114 105 110 103 59 1 0 10 83 111 117 114 99 101 70 105 108 101 1 0 15 72 101 108 108 111 87 111 114 108 100 46 106 97 118 97 0 33 0 2 0 4 0 0 0 0 0 2 0 1 0 5 0 6 0 1 0 7 0 0 0 47 0 1 0 1 0 0 0 5 42 183 0 9 177 0 0 0 2 0 10 0 0 0 6 0 1 0 0 0 14 0 11 0 0 0 12 0 1 0 0 0 5 0 12 0 13 0 0 0 9 0 14 0 15 0 1 0 7 0 0 0 55 0 2 0 1 0 0 0 9 178 0 21 18 23 182 0 29 177 0 0 0 2 0 10 0 0 0 10 0 2 0 0 0 16 0 8 0 17 0 11 0 0 0 12 0 1 0 0 0 9 0 30 0 31 0 0 0 1 0 32 0 0 0 2 0 33

A source file contains source code and is really just a simple text file. It contains (among other things) instructions for the computer to execute. A ``.java'' ending is used to distinguish it as a Java source file Java files have special structure so that the computer can translate it into machine code. Use a text editor or an IDE (in this class we use BlueJ but you can also use Eclipse) to create source and make changes to it. We'll make a simple "Hello World" program now!

10 min Break then Demo Pair Programming (Show Video) Pair up with the person sitting next to you One person types the other “steers” (checks for errors) Use BlueJ to write, compile, and run The “Hello World” program

Programming Languages New High level programming languages are being created all the time, to fill different tasks Some common programming languages: Java C Visual Basic BASIC C++ Python COBOL C# Ruby Pascal PHP JavaScript

Programming Languages Common Language Elements There are some concepts that are common to virtually all programming languages. Common concepts: Key words Operators Punctuation Programmer-defined identifiers Strict syntactic rules.

Programming Languages Sample Program public class HelloWorld { public static void main(String[] args) System.out.println("Hello World"); }

Programming Languages Sample Program Key words in the sample program are: Key words are lower case (Java is a case sensitive language). Key words cannot be used as a programmer-defined identifier. public class static void

Programming Languages Semi-colons are used to end Java statements; however, not all lines of a Java program end a statement. Part of learning Java is to learn where to properly use the punctuation.

Programming Languages Lines vs Statements There are differences between lines and statements when discussing source code. System.out.println( "Hello World"); This is one Java statement written using two lines. Do you see the difference? A statement is a complete Java instruction that causes the computer to perform an action.

Programming Languages Variables Data in a Java program is stored in memory. Variable names represent a location in memory. Variables in Java are sometimes called fields. Variables are created by the programmer who assigns it a programmer-defined identifier. example: int hours = 40; In this example, the variable hours is created as an integer (more on this later) and assigned the value of 40.

Programming Languages Variables Variables are simply a name given to represent a place in memory. 0x000 0x001 0x002 0x003 0x004 0x005 0x006 0x007

Programming Languages Variables 72 Assume that this variable declaration has been made. int length = 72; The variable length is a symbolic name for the memory location 0x003. 0x000 0x001 0x002 0x003 0x004 0x005 0x006 0x007 The Java Virtual Machine (JVM) actually decides where the value will be placed in memory.

Variables and println The System.out.println(); command can print out text in quotes, like "Hello World“ Or it can print the current value of a variable: System.out.println( length ); Would print 72 on the screen Or it can print text and a value: System.out.println("Length = " + length ); Would print Length = 72 on the screen

The value in a variable can change! If we add these statements after the previous length = 24; System.out.println(length); We will now see 24 on the screen The value stored in the length variable If we add the following, what will be displayed? length = length - 15;

Is your console output screen getting longer? You can add an “escape character” to erase the results of previous program executions Do this at the top of your program System.out.println("\f"); Means “flush (or erase) the console screen” Put only once near the top, the first thing printed You can even put \f in front of the H in Hello: System.out.println("\fHello World");

Add to your “Hello World” demo Create a variable to represent your age int age = 23; Write a statement to print “My age is ” and the value in age Write a statement to add the number 10 to your age variable Write a statement to print “In ten years I will be ” and the current value of age

The Programming Process 1. Clearly define what the program is to do. purpose, data in, processing, desired output 2. Visualize the program running on the computer. 3. Use design tools to create a model of the program. Pseudocode—cross between human/computer language 4. Check the model for logical errors.

The Programming Process 5. Enter the code and compile it. 6. Correct any errors found during compilation. Repeat Steps 5 and 6 as many times as necessary. 7. Run the program with test data for input. 8. Correct any runtime errors found while running the program. Repeat Steps 5 through 8 as many times as necessary. 9. Validate the results of the program.

Two Programming Paradigms Historically, there have been two approaches to developing complex programming projects Procedural Programming Object Oriented Programming Both are still in use today, altho OOP is favored We will be exposed to both of these paradigms in this class

Procedural Programming Older programming languages were procedural. A procedure is a set of programming language statements that, together, perform a specific task. Procedures typically operate on data items that are separate from the procedures. In a procedural program, the data items are commonly passed from one procedure to another.

Procedural Programming Data Element Procedure B Procedure A

Procedural Programming In procedural programming, procedures are developed to operate on the program’s data. Data in the program tends to be global to the entire program. Data formats might change and thus, the procedures that operate on that data must change. Procedural programming can be harder to maintain than OOP.

Object-Oriented Programming Object-oriented programming is centered on creating objects rather than procedures. Objects are a melding of data and procedures that manipulate that data. Data in an object are known as attributes. Procedures in an object are known as methods.

Object-Oriented Programming Attributes (data) Methods (behaviors / procedures) Physical Analogy: your iPod My iPod Attributes(data) playlist volume setting current track Methods play skip shuffle

Object-Oriented Programming Object-oriented programming combines data and behavior via encapsulation. Data hiding is the ability of an object to hide data from other objects in the program. Only an object’s methods should be able to directly manipulate its attributes. Other objects are allowed manipulate an object’s attributes via the object’s methods. This indirect access is known as a programming interface.

Object-Oriented Programming Attributes (data) typically private to this object Methods (behaviors / procedures) Other objects Programming Interface

To prepare for Lab1, please begin prelab1 For full credit, due by Midnight Wednesday Start now! Visit the website and click on the link. You can solve some, go home, solve others. When done, click “done” then “submit” to turn in Each problem has hard and easy mode. Hard: worth 1.1 pts Easy: worth 0.7 pts Once you switch to easy you can’t go back to hard