Welcome to CMPT 125/126 !
Introduction to Computer Science and Programming II Instructor : Scott Kristjanson TAs : Yu Yang, Megan O’Connor SFU Burnaby, Fall 2013
Welcome to CMPT 125/126 ! Introduction to Computer Science and - - PowerPoint PPT Presentation
Welcome to CMPT 125/126 ! Introduction to Computer Science and Programming II Instructor : Scott Kristjanson TAs : Yu Yang, Megan OConnor SFU Burnaby, Fall 2013 CMPT 125/126 Overview 2 Introduction to Computing Science and Programming II
Introduction to Computer Science and Programming II Instructor : Scott Kristjanson TAs : Yu Yang, Megan O’Connor SFU Burnaby, Fall 2013
Wk01.1 Slide 2
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
2
Scott Kristjanson – CMPT 125/126 – SFU
Wk01.1 Slide 3
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
3
Scott Kristjanson – CMPT 125/126 – SFU
General introduction Java Basics Review of Elementary programming:
Elementary data structures
Object-oriented concepts:
Recursion Fundamental algorithms
Design and Implementation of medium and large scale applications Analysis of Algorithms: Computability and complexity Exception handling File I/O and Dynamic data structures as time permits
Wk01.1 Slide 4
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
4
Scott Kristjanson – CMPT 125/126 – SFU
by J. Lewis, P. DePasquale, and J. Chase Available from the SFU Bookstore in hardcopy or as an on-line edition Library will have several copies available in the Reserve section of the library You might be able to get by with the second
numbers on a best-effort basis.
Wk01.1 Slide 5
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
5
Scott Kristjanson – CMPT 125/126 – SFU
the semester. You should read your SFU email account regularly, at least a few times each week.
Wk01.1 Slide 6
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
6
Scott Kristjanson – CMPT 125/126 – SFU
Tutorials contain a mix of demos, exercises, and one-on-one help from TA CSIL PCs can multi-boot either Windows or Linux Encouraged to work in pairs on Lab Exercises It is each student’s responsibility during your scheduled section to:
CMPT 125 Tutorials – Applied Sciences Building 9838 (CSIL) Section D101 – 09:30am – 10:20AM Section D102 – 10:30am – 11:20AM Section D103 – 11:30am – 12:20PM Section D104 – 12:30pm – 01:20PM CMPT 126 Tutorials – Applied Sciences Building 9838 (CSIL) Section D101 – 1:20pm – 2:20pm Section D102 – 3:30pm – 4:20pm Section D103 – 4:30pm – 5:20pm
Wk01.1 Slide 7
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
7
Scott Kristjanson – CMPT 125/126 – SFU
Note: Students must attain an overall passing grade on the weighted average
Students who do not obtain a passing grade in the final exam may not
Wk01.1 Slide 8
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
8
Scott Kristjanson – CMPT 125/126 – SFU
We take academic dishonesty very seriously in the School of Computing
If you are unclear on what academic dishonesty is, please read Policy 10.02. It can be found in the “Policies & Procedures” section in the SFU web site. Cheating on a lab or assignment will result in a mark of 0 on the piece of
academic dishonesty will also be recorded in your file, as is required by University policy. Any academic dishonesty on the midterm or final will result in a recommendation that an F be given for the course.
Wk01.1 Slide 9
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
9
Scott Kristjanson – CMPT 125/126 – SFU
Wk01.1 Slide 10
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
10
Scott Kristjanson – CMPT 125/126 – SFU
Wk01.1 Slide 11
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
11
Scott Kristjanson – CMPT 125/126 – SFU
Chapter 1 Introduction – Sections 1.2 to 1.5
Wk01.1 Slide 12
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
12
Scott Kristjanson – CMPT 125/126 – SFU
Wk01.1 Slide 13
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
13
Scott Kristjanson – CMPT 125/126 – SFU
“How can I implement an algorithm for my application on a PC in Java?”
Wk01.1 Slide 14
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
14
Scott Kristjanson – CMPT 125/126 – SFU
All steps should be clear and explicit
An algorithm should solve to a particular problem
An algorithm typically needs input to do its job
An algorithm is a set of instructions that can be used to solve a problem.[4]
Wk01.1 Slide 15
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
15
Scott Kristjanson – CMPT 125/126 – SFU
Wk01.1 Slide 16
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
16
Scott Kristjanson – CMPT 125/126 – SFU
(for large N, these problems can take billions of years to solve!)
(One solution prints “Yes”, another prints “No”, but which is correct?)
(One can prove that no such algorithm is possible!)
Wk01.1 Slide 17
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
17
Scott Kristjanson – CMPT 125/126 – SFU
Wk01.1 Slide 18
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
18
Scott Kristjanson – CMPT 125/126 – SFU
From Cmpt 120, it’s assumed that you will be familiar with the basic concepts of programming. (Section numbers refer to the course text.)
There is no expectation that you will know the precise Java syntax for these concepts, only that you know the concepts. Over the first few weeks
Wk01.1 Slide 19
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
19
Scott Kristjanson – CMPT 125/126 – SFU
In this course, you will also be learning some new tools:
Development Kit (SDK).
Why Linux, Eclipse, and the Command Line?
foundation for future courses and the job market
Can I use other environments like Windows and NetBeans? Yes but…
You may develop on Windows using Eclipse, NetBeans, or JCreator But TEST it on Linux before submitting!
Wk01.1 Slide 20
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
20
Scott Kristjanson – CMPT 125/126 – SFU
Stripped of complexity, a simple computer looks like this: 1. Programs are loaded from disk and into Main Memory 2. The CPU interprets the 1’s and 0’s in memory as instructions 3. CPU interacts with i/o devices to perform some task
These instructions of 1’s and 0’s are called Machine Language. Definitely NOT Java!
Wk01.1 Slide 21
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
21
Scott Kristjanson – CMPT 125/126 – SFU
(SPUs)
It’s the processor inside of the Sony PlayStation 3 and Xbox 360[8]
(SPUs)
(SPUs)
Wk01.1 Slide 22
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
22
Scott Kristjanson – CMPT 125/126 – SFU
The mechanics of developing a program include several activities
Software tools can be used to help with all parts of this process
Wk01.1 Slide 23
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
23
Scott Kristjanson – CMPT 125/126 – SFU
There are four programming language levels
Each type of CPU has its own specific machine language The other levels were created to make it easier for a human being to read and write programs
Wk01.1 Slide 24
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
24
Scott Kristjanson – CMPT 125/126 – SFU
Wk01.1 Slide 25
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
25
Scott Kristjanson – CMPT 125/126 – SFU
Wk01.1 Slide 26
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
26
Scott Kristjanson – CMPT 125/126 – SFU
Wk01.1 Slide 27
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
27
Scott Kristjanson – CMPT 125/126 – SFU
The Java compiler translates Java source code into a special representation called bytecode Java bytecode is not the machine language for any traditional CPU Another software tool, called an interpreter, translates bytecode into machine language and executes it Therefore the Java compiler is not tied to any particular machine Java is considered to be architecture-neutral Just-in-Time compiler translates Bytecode into Machine code
Wk01.1 Slide 28
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
28
Scott Kristjanson – CMPT 125/126 – SFU
Wk01.1 Slide 29
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
29
Scott Kristjanson – CMPT 125/126 – SFU
Wk01.1 Slide 30
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
30
Scott Kristjanson – CMPT 125/126 – SFU
There are many environments that support the development of Java software, including:
Though the details of these environments differ, the basic compilation and execution process is essentially the same Eclipse, in particular, will seem complex and intimidating. Don’t panic! You’ve used similar tools before, you just have to recognize the
All three IDEs come pre-installed in CSIL but only Eclipse works on Linux
Wk01.1 Slide 31
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
31
Scott Kristjanson – CMPT 125/126 – SFU
Wk01.1 Slide 32
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
32
Scott Kristjanson – CMPT 125/126 – SFU
Wk01.1 Slide 33
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
33
Scott Kristjanson – CMPT 125/126 – SFU
time errors)
by zero, which causes a program to terminate abnormally (run-time errors)
incorrect formula (logical errors) or having a race condition (Heizenbugs)
Wk01.1 Slide 34
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
34
Scott Kristjanson – CMPT 125/126 – SFU
The purpose of writing a program is to solve a problem Solving a problem consists of multiple activities
These activities are not purely linear – they should overlap and interact
Wk01.1 Slide 35
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
35
Scott Kristjanson – CMPT 125/126 – SFU
Wk01.1 Slide 36
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
36
Scott Kristjanson – CMPT 125/126 – SFU
Software development consists of four basic development activities:
These steps also are never purely linear and often overlap and interact
Wk01.1 Slide 37
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
37
Scott Kristjanson – CMPT 125/126 – SFU
these requirements
the problem
problem given all of the constraints under which it must perform
Wk01.1 Slide 38
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
38
Scott Kristjanson – CMPT 125/126 – SFU
Wk01.1 Slide 39
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
39
Scott Kristjanson – CMPT 125/126 – SFU
Wk01.1 Slide 40
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
40
Scott Kristjanson – CMPT 125/126 – SFU
Wk01.1 Slide 41
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
41
Scott Kristjanson – CMPT 125/126 – SFU
Wk01.1 Slide 42
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
42
Scott Kristjanson – CMPT 125/126 – SFU
Wk01.1 Slide 43
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
43
Scott Kristjanson – CMPT 125/126 – SFU
Wk01.1 Slide 44
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
44
Scott Kristjanson – CMPT 125/126 – SFU
solve problems
Machine Code and write portable code
Java programs
Wk01.1 Slide 45
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
45
Scott Kristjanson – CMPT 125/126 – SFU
1.
Program Design & Data Structures. Addison-Wesley, Boston, Massachusetts, 3rd edition, 2014, ISBN 978-0-13-337046-1 2. Brooks, Frederick P., No Silver Bullet: Essence and Accidents of Software Engineering, IEEE Computer, Vol. 20, No. 4 (April 1987) pp. 10-19, http://www.cgl.ucsf.edu/Outreach/pc204/NoSilverBullet 3. Top 10 Most Popular Programming Languages website, http://www.english4it.com/reading/40 4.
Science and Programming I, Fall 2010 Edition, http://www2.cs.sfu.ca/CourseCentral/120/ggbaker/guide/guide 5.
6.
7.
8.
Architecture, IBM J. Res. & Dev. Vol. 51 No. 5 September 2007, pp. 503-519
Wk01.1 Slide 46
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
46
Scott Kristjanson – CMPT 125/126 – SFU
– Cmpt 125/126 Spring 2012
– Cmpt 126/126 Summer 2013
– Cmpt 120 Fall 2010
Wk01.1 Slide 47
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase And course material from Diana Cukierman, Lou Hafer, and Greg Baker
47
Scott Kristjanson – CMPT 125/126 – SFU