math 107 introduction to scientific programming. s.horton/107/ch. 1slide 2 acknowledgements …...

26
Math 107 Introduction To Scientific Programming

Upload: ursula-dennis

Post on 11-Jan-2016

229 views

Category:

Documents


6 download

TRANSCRIPT

Page 1: Math 107 Introduction To Scientific Programming. S.Horton/107/Ch. 1Slide 2 Acknowledgements … Portions of these notes reproduce charts, slides, and tables

Math 107

Introduction To Scientific Programming

Page 2: Math 107 Introduction To Scientific Programming. S.Horton/107/Ch. 1Slide 2 Acknowledgements … Portions of these notes reproduce charts, slides, and tables

S.Horton/107/Ch. 1 Slide 2

Acknowledgements …

Portions of these notes reproduce charts, slides, and tables from:

Java Software Solutions, 4th Edition (2005), by Lewis & Loftus

Java: An Introduction To Computer Science & Programming, 3rd Edition (2004), by W. Savitch

Some screen shots are:

© Microsoft Corporation

Other Acknowledgements:

Solaris, Java, Java Beans, and JS2E SDK are © Sun Corporation

Windows and Window XP are © Microsoft Corporation

JCreator Pro and JCreator LE are © Xinox Corporation

Page 3: Math 107 Introduction To Scientific Programming. S.Horton/107/Ch. 1Slide 2 Acknowledgements … Portions of these notes reproduce charts, slides, and tables

S.Horton/107/Ch. 1 Slide 3

Welcome To…

Garbage in, Garbage out.

- A common programmer’s lament.

Page 4: Math 107 Introduction To Scientific Programming. S.Horton/107/Ch. 1Slide 2 Acknowledgements … Portions of these notes reproduce charts, slides, and tables

S.Horton/107/Ch. 1 Slide 4

Course Philosophy

I have three major instructional goals for this class that can be summed up in:

“Scientific Software Development in Java”

Page 5: Math 107 Introduction To Scientific Programming. S.Horton/107/Ch. 1Slide 2 Acknowledgements … Portions of these notes reproduce charts, slides, and tables

S.Horton/107/Ch. 1 Slide 5

Course Philosophy - III. Scientific

Use computers to solve quantitative/scientific problems in math, science, economics, …

II. Software Development Learn the process used to develop successful software

programs; Learn algorithms and special data/control structures to

solve problems;

III. Java Learn a programming language called Java that can

instruct a computer how to operate and handle data.

Page 6: Math 107 Introduction To Scientific Programming. S.Horton/107/Ch. 1Slide 2 Acknowledgements … Portions of these notes reproduce charts, slides, and tables

S.Horton/107/Ch. 1 Slide 6

Math 107 & 107L Logistics

Syllabus Walkthrough Instructor/Contact Info Course Material: Book/CD (Get Some Floppies) Lab

Hours: M-F 8:00 am – 6:30 pm (Check posting) Computer Access – “Lab Packet”

JCreator download: http://www.jcreator.com/ Sun Java Web site: http://java.sun.com

Page 7: Math 107 Introduction To Scientific Programming. S.Horton/107/Ch. 1Slide 2 Acknowledgements … Portions of these notes reproduce charts, slides, and tables

S.Horton/107/Ch. 1 Slide 7

How To Succeed In This Class

Read material BEFORE class

Quickly setup/learn JCreator IDE

Programming Projects Be prepared to iterate (cycle through multiple times) Be prepared to spend more time on software

development outside of the lab

Optional – Setup JCreator outside of lab for extra convenience

Page 8: Math 107 Introduction To Scientific Programming. S.Horton/107/Ch. 1Slide 2 Acknowledgements … Portions of these notes reproduce charts, slides, and tables

S.Horton/107/Ch. 1 Slide 8

Course Introduction

I. Before software, there is hardware!

II. Introduction to Java

III. Software design methodology

IV. Getting started

Page 9: Math 107 Introduction To Scientific Programming. S.Horton/107/Ch. 1Slide 2 Acknowledgements … Portions of these notes reproduce charts, slides, and tables

S.Horton/107/Ch. 1 Slide 9

I. A Crash Course in “PC Computer Hardware”

You need to understand the hardware platform before you develop software for it! Many types of hardware platforms

PCs / Mainframes/ Laptops Cell Phones / PDAs / Pocket PCs Embedded Systems: Medical Devices, Machines, …

Different Computing Models Client/Server, Enterprise/Server Distributed (VPN) Network Appliance/”Thin” Client Mobile/Wireless

Page 10: Math 107 Introduction To Scientific Programming. S.Horton/107/Ch. 1Slide 2 Acknowledgements … Portions of these notes reproduce charts, slides, and tables

S.Horton/107/Ch. 1 Slide 10

Simplified Schematic of PC Architecture

Keyboard

Mouse

Internet

RAM or DRAM

CPU

“Hard drive”

Software programs routinely have to manage some or all of these resources efficiently

Page 11: Math 107 Introduction To Scientific Programming. S.Horton/107/Ch. 1Slide 2 Acknowledgements … Portions of these notes reproduce charts, slides, and tables

S.Horton/107/Ch. 1 Slide 11

Micrograph of CPU Core

Control Unit

Registers

CPU Memory or “Cache”

ALU

Page 12: Math 107 Introduction To Scientific Programming. S.Horton/107/Ch. 1Slide 2 Acknowledgements … Portions of these notes reproduce charts, slides, and tables

S.Horton/107/Ch. 1 Slide 12

Simplified PC Program Execution Model

1) OS loads executable code into Main Memory

2) Control unit fetches first line of executable code

3) Fetch-Decode-Execute cycle is initiated

Page 13: Math 107 Introduction To Scientific Programming. S.Horton/107/Ch. 1Slide 2 Acknowledgements … Portions of these notes reproduce charts, slides, and tables

S.Horton/107/Ch. 1 Slide 13

II. Introduction to JAVA

History First conceived at Sun in 1991 to program

toasters!

Inventor James Gosling apparently decided the name while out at a (what else) coffee shop.

Oak – To Java – To Java Eveywhere.

Recently, a big fight over Microsoft’s non-authorized modifications for Windows (J++).

Page 14: Math 107 Introduction To Scientific Programming. S.Horton/107/Ch. 1Slide 2 Acknowledgements … Portions of these notes reproduce charts, slides, and tables

S.Horton/107/Ch. 1 Slide 14

Introduction to Java Main Attributes

General purpose programming language with all of the modern elements of OOP (encapsulation/ inheritance/ polymorphism…)

Syntax similar to C/C++

Portability - “Write once, run many…”

Also runs in web browsers (Applets) which means most types of computers

Not controlled by Microsoft (controlled by Sun)

Page 15: Math 107 Introduction To Scientific Programming. S.Horton/107/Ch. 1Slide 2 Acknowledgements … Portions of these notes reproduce charts, slides, and tables

S.Horton/107/Ch. 1 Slide 15

The Java Software Development Model – “Write Once, Run Many”

J2SE (MS Windows)

JCreator

Portable “Applets”

Input

The biggest difference between this and some other development models is that the compilation process has been split into two parts

Java Virtual Machine (JVM)

Page 16: Math 107 Introduction To Scientific Programming. S.Horton/107/Ch. 1Slide 2 Acknowledgements … Portions of these notes reproduce charts, slides, and tables

S.Horton/107/Ch. 1 Slide 16

What Java Is Not – Assembler Language

Page 17: Math 107 Introduction To Scientific Programming. S.Horton/107/Ch. 1Slide 2 Acknowledgements … Portions of these notes reproduce charts, slides, and tables

S.Horton/107/Ch. 1 Slide 17

The Popularity of Java - The World Wide Web!

Page 18: Math 107 Introduction To Scientific Programming. S.Horton/107/Ch. 1Slide 2 Acknowledgements … Portions of these notes reproduce charts, slides, and tables

S.Horton/107/Ch. 1 Slide 18

UCSD Supercomputer Center Internet Visualization Project

Page 19: Math 107 Introduction To Scientific Programming. S.Horton/107/Ch. 1Slide 2 Acknowledgements … Portions of these notes reproduce charts, slides, and tables

S.Horton/107/Ch. 1 Slide 19

III. Software Design Methodology - Single Person Design Cycle

Design

Code

Run

Test

Bu

llet

-Pro

ofi

ng

Deb

ug

Pai

nfu

l &

Tim

e C

on

sum

ing

!

Deploy

Page 20: Math 107 Introduction To Scientific Programming. S.Horton/107/Ch. 1Slide 2 Acknowledgements … Portions of these notes reproduce charts, slides, and tables

S.Horton/107/Ch. 1 Slide 20

Major Goals in Software Design

1. Operational (Customer)• Does it work?• Does it meet the design specification?

2. Performance (Customer)• Is it efficient (Speed/Memory/Disk Space)?• Can it handle errors?

3. Maintainable (Programmer)• Is it understandable?• Is it modifiable?

Page 21: Math 107 Introduction To Scientific Programming. S.Horton/107/Ch. 1Slide 2 Acknowledgements … Portions of these notes reproduce charts, slides, and tables

S.Horton/107/Ch. 1 Slide 21

IV. Getting Started!

1. Start the JCreator IDE

2. Input source code

3. Compile & Run

Page 22: Math 107 Introduction To Scientific Programming. S.Horton/107/Ch. 1Slide 2 Acknowledgements … Portions of these notes reproduce charts, slides, and tables

S.Horton/107/Ch. 1 Slide 22

JCreator Integrated Development Environment (IDE)

Page 23: Math 107 Introduction To Scientific Programming. S.Horton/107/Ch. 1Slide 2 Acknowledgements … Portions of these notes reproduce charts, slides, and tables

S.Horton/107/Ch. 1 Slide 23

The Traditional And Famous Hello World Program!

/* MyFirstJavaProgram is the Java version* of the famous and traditional Hello* World program which writes Hello world * to the console window.** Author: S. Horton* Date: 8/01/03* */

public class MyFirstJavaProgram { public static void main(String[] args) { System.out.println("Hello world!"); }}

Page 24: Math 107 Introduction To Scientific Programming. S.Horton/107/Ch. 1Slide 2 Acknowledgements … Portions of these notes reproduce charts, slides, and tables

S.Horton/107/Ch. 1 Slide 24

Select New-File, Input A Name & Path, Type Code Into Editor

Page 25: Math 107 Introduction To Scientific Programming. S.Horton/107/Ch. 1Slide 2 Acknowledgements … Portions of these notes reproduce charts, slides, and tables

S.Horton/107/Ch. 1 Slide 25

Click Compile, Check For Errors, Click Run

Page 26: Math 107 Introduction To Scientific Programming. S.Horton/107/Ch. 1Slide 2 Acknowledgements … Portions of these notes reproduce charts, slides, and tables

S.Horton/107/Ch. 1 Slide 26

If You Succeed …