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
CMPT 125/126 Overview
2
Introduction to Computing Science and Programming II
 An introduction to computing science and computer
programming in the Java Programming Language
 Suitable for students who already have some background in
computing science and programming
 Intended for students who will major in computing science or
a related program
A Single Course with Two Course numbers:
 CMPT 125 – Students who have completed CMPT 120
 CMPT 126 – Students with experience in programming
 Combined in CourSys as CMPT_125_X1
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 2
Course Topics
3
General introduction
Java Basics
Review of Elementary programming:
• basic data types and conversions
• control: if-then-else, for, while
• subroutines, modularity, packages
Elementary data structures
• arrays, linked lists, stacks, queues
Object-oriented concepts:
• objects, classes, encapsulation
• Inheritance, overloading, and polymorphism
• Iterators, Abstract Data Types
Recursion
Fundamental algorithms
• Sorting and Searching
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
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 3
Required Text:
4
Java Foundations:
Introduction to Program Design &
Data Structures, 3rd Edition [1]
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
edition. I will provide corresponding section
numbers on a best-effort basis.
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 4
Course Web Resources
5
Course Description available via Course Central:
http://www.cs.sfu.ca/CC/
Course Webpage:
http://www.cs.sfu.ca/CourseCentral/125/skristja/
•
•
•
•
Course Outline and Schedules
Assignments and Due Dates
Link to course online discussion forum (Canvas system)
Marking Schemes and Solutions
Email Communications:
• Email questions to your TAs or instructor directly,
or send email to [email protected]
• The TAs and instructor will use email to send announcements and tips during
the semester. You should read your SFU email account regularly, at least a
few times each week.
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 5
Tutorials
6
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:
•
•
•
•
•
•
•
•
Attend and sit at a PC near the North Projection Screen
Read Lab Exercises ahead of time and be prepared
Watch Lab Demos and ask questions
Complete any work specified in the Lab Exercises by the Due Date
Submit completed exercises on-line if specified to do so in the Lab Exercises
Ensure to check in with TA for attendance before you leave
Logout at the end of Tutorial to make room for students in next Section
You can continue your work on another PC in the same general area of CSIL
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
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 6
Course Marking Scheme
7
10%
2%
3%
15%
20%
50%
-
Labs (5% Participation, 5% Lab Exercises)
Academic Enhancement Program (AEP)
Quizzes
Assignments
Midterm
Final Exam
Note:
Students must attain an overall passing grade on the weighted average
of exams in the course in order to obtain a clear pass (C- or better).
Students who do not obtain a passing grade in the final exam may not
obtain a pass (D or better).
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 7
Academic Dishonesty[4][5][6]
8
We take academic dishonesty very seriously in the School of Computing
Science. Academic dishonesty includes (but is not limited to) the following:
•
•
•
•
•
copying another student’s assignment
allowing others to complete work for you
allowing others to use your work
copying part of an assignment from an outside source
cheating in any way on a test or examination
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
work. At the instructor’s option, further penalties may be requested. Any
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.
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 8
By the end of this course…
9
You should be able to:
 Describe some of the basic ideas of computer science
 Explain what Algorithms and computer programming are
 Identify Software Engineering principles of good design
 Design Data Structures appropriate to solve problems
 Design Algorithms to solve moderately complex problems
 Use Object Oriented concepts in your design
 Write Programs in the Java Programming Language
 Run and Test Java Programs in an IDE such as Eclipse
 Create Programs that are easy to understand and maintain
 Analyze how much memory and time an algorithm will take
Keep these goals in mind as you progress through the course
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 9
Now let’s get started with CMPT 125/126
10
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 10
Introduction
11
Chapter 1
Introduction – Sections 1.2 to 1.5
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 11
We are going to embark on a Journey
12
Through the world of:
• Data Structures
• Algorithms
• Computer Programs using a high level language called Java
In order to Solve Problems
• That’s the purpose of writing computer programs!
• Java is just a tool, these concepts apply to many languages.
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 12
How does CMPT125/126 fit into Computing Science? [7]
13
Computing science is the study of algorithms and their:
•
•
•
•
Formal and mathematical properties
Hardware realizations
Linguistic realizations
Application of algorithms to solve problems
Cmpt 125 focussed on the Application of algorithms
Other courses exist which focus on the other aspects:
• Formal and mathematical properties (CMPT 225/307/450)
• Hardware Architectures (CMPT150/250)
• Programming languages (CMPT383)
We can sum up the goal of this course with the question:
“How can I implement an algorithm for my application on a PC in Java?”
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 13
What is an Algorithm?
14
The concept of an “algorithm” is fundamental to all of
computing science and programming.
An algorithm is a sequence of unambiguous instructions
for solving a problem, i.e., for obtaining a required output
for any legitimate input in a finite amount of time.
Notice some important key words in the definition:
• Unambiguous:
• Problem:
• Legitimate input:
• Finite amount of time:
All steps should be clear and explicit
An algorithm should solve to a particular problem
An algorithm typically needs input to do its job
If we start the algorithm, it had better finish eventually
Stated simply:
An algorithm is a set of instructions that can be used to solve a problem.[4]
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 14
What kind of problems can Algorithms solve?
15
The kind of applications you use everyday:
• Smart Phones
• Websites
• Games
But also the kind of research happening at SFU right now:
•
•
•
•
•
•
•
•
•
•
Mapping diseases to the human genome using the Cloud and Big Data
Mapping patient brain function for improving brain surgery results
Early detection of Skin Cancers using Smart Phones
Energy saving techniques for Smartphone's
Real-time encoding of Video for smart-phones with Cloud Computing
Improved Multimedia Encoding Algorithms
Faster Graphics and Computer Vision and Artificial Intelligence
Bioinformatics, Robotics, Bio-molecular Computing
Improved Computer Architecture Designs
Telecoms, Networks and Graph Theory, Network Usage Algorithms
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 15
Are there any problems Algorithms Cannot Solve?
16
Yes! 
Some problems just take too long, they are intractable:
• Finding optimal packing of N items in a backpack to maximize value
• Finding the most energy efficient folding of a protein of length N
(for large N, these problems can take billions of years to solve!)
Some problems are easily computed but undecidable:
• Does the decimal expansion of PI have a sequence of 7’s of length N?
(One solution prints “Yes”, another prints “No”, but which is correct?)
Some problems are not computable with ANY algorithm:
• Given an program to analyze, determine if the program ever halts
(One can prove that no such algorithm is possible!)
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 16
Problem Solving
17
Solving a problem consists of multiple activities:
•
•
•
•
•
Understanding the problem
Designing a solution, representing the information
Considering alternatives and refining the solution
Implementing the solution
Testing the solution …..
And do it all over again!…
These activities are not purely linear,
they overlap and interact
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 17
Building on Your Existing Knowlege
18
From Cmpt 120, it’s assumed that you will be familiar with the basic
concepts of programming. (Section numbers refer to the course text.)
•
•
•
•
•
•
•
•
Data types and conversions (§§2.1 – 2.3, 2.5)
Expressions (§2.4)
Strings (§3.2)
Libraries (§3.3). These are called modules in Python, packages in Java.
Conditionals (if-then-else) (§§4.1, 4.2)
Definite (for) and indefinite (while) loops (§§4.5, 4.7, 4.8)
Subroutines (§5.4).
Subroutines are usually associated with objects in Java and are called
methods. It is also possible to define stand-alone subroutines.
• Basic terminal input/output (§2.6)
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
of the course we will learn how they are expressed in Java.
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 18
New Tools to Learn
19
In this course, you will also be learning some new tools:
• For most of you, a new operating system: Linux
• Command line tools ( javac, java, javadoc) that come with the Java Software
Development Kit (SDK).
• Various Interactive Development Environments (IDE’s) such as Eclipse
Why Linux, Eclipse, and the Command Line?
• Combination considered to be a professional set of tools – very efficient
• Eclipse IDE has more than you need for this course, you are building a
foundation for future courses and the job market
• Command Line often used in industry to build and test automatically
Can I use other environments like Windows and NetBeans?
Yes but…
• TAs will be using Linux and Command Line to test your Assignments
• If TA cannot compile and run your assignment in Linux, you get ZERO.
You may develop on Windows using Eclipse, NetBeans, or JCreator
But TEST it on Linux before submitting!
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 19
A little more on ‘Hardware Realization’
20
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!
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 20
A More Complicated Computer…
21
Cell Broadband Engine by Sony, Toshiba, and IBM:
• a set of IBM PowerPC 64-bit Processor Units (PPUs)
• a set of Graphical Processing Units
(SPUs)
Do you recognize it?
It’s the processor inside of the Sony PlayStation 3 and Xbox 360[8]
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 21
Program Development
22
The mechanics of developing a program include several activities
• writing the program in a specific programming language (such as Java)
• translating the program into a form that the computer can execute
• investigating and fixing various types of errors that can occur
Software tools can be used to help with all parts of this process
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 22
Language Levels
23
There are four programming language levels
•
•
•
•
machine language
assembly language
high-level language
fourth-generation language
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
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 23
Language Levels
24
A high-level expression and its lover level equivalents:
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 24
Compilation
25
Each type of CPU executes only a particular machine language
A program must be translated into machine language before it can be
executed
A compiler is a software tool which translates source code into a
specific target language
Often, that target language is the machine language for a particular
CPU type
The Java approach is somewhat different
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 25
Basic Programming Steps
26
A program is written in an editor, compiled into an executable
form, and then executed
If errors occur during compilation, an executable version is not
created
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 26
Java Translation
27
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
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 27
Why Java instead of Python?
28
Python:
•
•
•
•
Considered a scripting language in industry, seldom used in products
Does not scale up well for large complex programs
Interpreted language is not efficient use of resources
Simple structure easy to learn, but allows errors to go undetected
• Program Structure defined by indenting levels only
• Local variables declared implicitly, this allows typos to go undetected
Java has several advantages:
•
•
•
•
Most popular language in industry [3] - Write-Once-Run-Everywhere
Modular structure and package concepts scale well to large programs
Just-in-Time Compilation makes more efficient use of resources
More complex structure helps catch errors at compile time
• Classes and Methods defined by enclosing braces {}
• All variables must be declared so typos cause compile errors
• Stronger type checking
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 28
Development Environments
29
A development environment is the set of tools used to create,
test, and modify a program
An integrated development environment (IDE) combine the
tools into one software program
All development environments contain key tools, such as a
compiler and interpreter
Others include additional tools, such as a debugger, which
helps you find errors
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 29
Integrated Development Environments
30
There are many environments that support the development of Java
software, including:
• Eclipse
• NetBeans
• JCreator
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
resemblance. Very similar to a DVD Burner program:
• Invoke the program and it pops up a GUI with several window panes
• A pane exists to move files and assemble your project
• Another pane contains controls for building your project
All three IDEs come pre-installed in CSIL but only Eclipse works on Linux
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 30
Eclipse Example IDE Screenshot
31
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 31
Syntax and Semantics
32
The syntax rules of a language define how we can put
together symbols, reserved words, and identifiers to make a
valid program
The semantics of a program statement define what that
statement means (its purpose or role in a program)
A program that is syntactically correct is not necessarily
logically (semantically) correct
A program will always do what we tell it to do, not what we
meant to tell it to do
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 32
Errors
33
A program can have three types of errors:
 The compiler will find syntax errors and other basic problems (compiletime errors)
 A problem can occur during program execution, such as trying to divide
by zero, which causes a program to terminate abnormally (run-time
errors)
 A program may run, but produce incorrect results, perhaps using an
incorrect formula (logical errors) or having a race condition (Heizenbugs)
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 33
Problem Solving
34
The purpose of writing a program is to solve a problem
Solving a problem consists of multiple activities
•
•
•
•
•
understand the problem
design a solution
consider alternatives and refine the solution
implement the solution
test the solution
These activities are not purely linear – they should overlap and interact
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 34
Problem Solving
35
The key to designing a solution is breaking it down into
manageable pieces
When writing software, we design separate pieces that are
responsible for certain parts of the solution
An object-oriented approach lends itself to this kind of solution
decomposition
We will dissect our solutions into pieces called objects and
classes
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 35
Development Activities
36
Software development consists of four basic development activities:
•
•
•
•
establishing the requirements
creating a design
implementing the design
Testing
These steps also are never purely linear and often overlap and interact
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 36
Development Activities
37
Establish the Requirements:
Software requirements specify what a program must accomplish
• A Functional Specification document captures what the requirements are
Create a design:
• A Software Design document indicates how a program will implement
these requirements
Implement the Design:
• Implementation is the process of writing the source code that will solve
the problem
Testing
• Testing is the act of validating that a program will solve the intended
problem given all of the constraints under which it must perform
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 37
Object-Oriented Programming
38
Java is an object-oriented programming language
As the term implies, an object is a fundamental entity in a
Java program
Objects can be used effectively to represent real-world entities
For instance, an object might represent a particular employee
in a company
Each employee object handles the processing and data
management related to that employee
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 38
Objects
39
An object has
• state - descriptive characteristics
• behaviors - what it can do (or what can be done to it)
The state of a bank account includes its account number and
its current balance
The behaviors associated with a bank account include the
ability to make deposits and withdrawals
Note that the behavior of an object often changes its state
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 39
Classes
40
An object is defined by a class
A class is the blueprint of an object
The class uses methods to define the behaviors of the object
The class that contains the main method of a Java program
represents the entire program
A class represents a concept, and an object represents an
instantiation of that concept
Multiple objects can be created from the same class
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 40
Classes and Objects
41
A class is like a blueprint from which you can create many of
the "same" house with different characteristics
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 41
Classes and Objects
42
An object is encapsulated, protecting the data it manages
One class can be used to derive another via inheritance
Classes can be organized into hierarchies
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 42
Classes and Objects
43
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 43
Summary
44
Key Things to take away from this presentation:
• Computer systems consist of hardware and software that work in concert to help us
solve problems
• All programs must be translated into a CPU’s Machine Code before it can be executed
• High-level Languages like Java allow a programmer to ignore CPU specific details of
Machine Code and write portable code
• Many different development environments exist to help you create, test, and modify
Java programs
• Syntax rules dictate the form of a program. Semantics dictate meaning of statements.
• A Java program must be syntactically correct or the compiler will not produce ByteCode
• Problem Solving involves breaking a problem into smaller pieces
• Each Object has a state defined by attributes, and behaviours defined by methods.
• A Class is a blueprint for creating object instances. Multiple objects can be created from
one class definition.
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 44
References:
45
1.
J. Lewis, P. DePasquale, and J. Chase., Java Foundations: Introduction to
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.
G. Baker, The Computing Science 120 Study Guide: Introduction to Computing
Science and Programming I, Fall 2010 Edition,
http://www2.cs.sfu.ca/CourseCentral/120/ggbaker/guide/guide
5.
L. Hafer, Computing Science 125/126 Course Notes, Summer 2013
6.
D. Cukierman, Computing Science 125/126 Course Notes, Spring 2012
7.
G. Michael Schneider and Judith L. Gersting, An Invitation to Computer Science
8.
C. R. Johns, D. A. Brokenshire, Introduction to the Cell Broadband Engine
Architecture, IBM J. Res. & Dev. Vol. 51 No. 5 September 2007, pp. 503-519
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 45
Thanks to past Cmpt125/126 Instructors
46
For permission to use and adapt their course material
• Diana Cukierman – Cmpt 125/126
• Lou Hafer
– Cmpt 126/126
• Greg Baker
– Cmpt 120
Spring 2012
Summer 2013
Fall 2010
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 46
Time for Questions
47
Scott Kristjanson – CMPT 125/126 – SFU
Slides based on Java Foundations 3rd Edition, Lewis/DePasquale/Chase
And course material from Diana Cukierman, Lou Hafer, and Greg Baker
Wk01.1 Slide 47
Descargar

Cmpt 125/126 Lecture Notes - wk01.1