Robert Salkin - PowerPoint PPT Presentation

1 / 29
About This Presentation
Title:

Robert Salkin

Description:

A device that performs calculations. How does a fancy calculator help me? ... Data from an Input Device waiting to be processed. Processed data waiting to be ... – PowerPoint PPT presentation

Number of Views:47
Avg rating:3.0/5.0
Slides: 30
Provided by: rob1125
Category:
Tags: dev | qa | robert | salkin | slowdown

less

Transcript and Presenter's Notes

Title: Robert Salkin


1
Introduction
  • Robert Salkin
  • CSI 205 OOP using Java
  • Summer 2005, 6W1

2
About Me
  • From NYC
  • Have been in Albany for 5 years to attend UAlbany
  • You dont have to start CS in your Freshman year
    to do well. Ive majored in
  • Biology (Pre-Med)
  • Business
  • Information Technology
  • Computer Science

3
About Me
  • Education
  • Bronx HS of Science, June 2000
  • BS Computer Science, May 2004
  • MS Computer Science, Dec 2005
  • Research
  • Image Segmentation
  • Robotics
  • Hashing Algorithm
  • Information Retrieval/Question Answering

4
About Me
  • Experience
  • Worked for UAlbany ResNet
  • http//resnet.albany.edu/
  • Research Assistant on a multi-million dollar
    government grant to produce a QA system for the
    intelligence community
  • http//www.hitiqa.albany.edu/
  • Teaching Assistant
  • CSI201 (3 semesters)
  • CSI210
  • CSI333
  • CSI402
  • CSI445
  • Lectured for Robotics, Spring 2004 Spring 2005
  • http//aquarius.ils.albany.edu/robotics/

5
How Ive used Java
  • Question Answering
  • Worked on a system to make it easier for people
    to get information
  • Robotics
  • See Demo...
  • Controller GUI
  • Image Segmentation tool

6
About the Course
  • The goal of this course is to provide a
    comprehensive introduction to Object Oriented
    Programming (OOP) using the Java programming
    language. This course aims to teach OOP concepts,
    such as classes, interfaces, inheritance, and
    polymorphism. In the process, this course will
    cover how create Java programs (applications and
    applets), from start to finish, including correct
    syntax, coding style, and common errors. Lectures
    will cover selected predefined Java classes and
    methods, and how to create user-defined classes,
    methods, and packages. Programming projects will
    focus on practicing OOP.
  • At the end of the course, youll know what that
    means. ?
  • See course website http//www.cs.albany.edu/salk
    in/csi205/
  • Office Hours?
  • Study Group/Online Bulletin Board?

7
Important Rules
  • It is my job to teach you what you need to know.
    Therefore
  • Ask me questions. Do NOT let me continue if you
    arent clear about something.
  • If I go too fast, ask me to slow down.
  • If I use a term that you arent familiar with,
    ask me for a definition.

8
Why Java?
  • Platform Independent (in theory)
  • Can run on any machine the same way.
  • Forces OOP
  • Maybe more annoying at first, but better in the
    long run.
  • Open Source
  • Free is always good!
  • Great API
  • Predefined operations with good documentation
    save time.

9
Why Java?
  • Easy Graphics
  • Graphics are (debatably) much more complicated to
    use in other languages.
  • Similar to C
  • C has been a widely accepted language for many
    years, so the transition to Java for a C
    programmer is relatively easy.
  • Widely Accepted
  • Java seems to be replacing C in many places.
  • Marketable Skill
  • Some companies wont hire people without Java
    skills. C is close, but may not be enough.

10
History of Java
  • At Sun Microsystems in 1991, project Green was
    launched.
  • James Gosling developed a language based on C
    syntax.
  • Originally called Oak, after the tree outside
    Goslings office.
  • It was learned that the name Oak was already
    taken, so Java was suggested while sitting in a
    coffee shop.

11
History of Java
  • World Wide Web started becoming more popular with
    consumers in 1993
  • Sun realized that Java could be used for dynamic
    content online
  • Java went public in May 1995 at a conference
  • Java is now used for applications on desktops,
    the web, and electronics

12
Take a step back
  • What is a computer?
  • A device that performs calculations.
  • How does a fancy calculator help me?
  • Electrical Engineers developed a way to turn
    little lights on and off based on a series of
    electrical pulses sent down a wire.
  • Display a picture on a Monitor.
  • They also developed a way to turn switches on and
    off based on a series of electrical pulses sent
    down another wire.
  • Get input from the Keyboard.

13
The Computer
  • Computers are made up of switches
  • Great for holding data in Binary (1/0) format.
  • Computers take input and produce output
  • Input Devices
  • Keyboard
  • Scanner
  • Output Devices
  • Monitor
  • Printer
  • Input/Output (I/O) Devices
  • Hard Disk
  • Network Connection

14
The Computer
  • But, how does it know what to output when it gets
    a particular input?
  • Programmers write instructions for the computer.
  • The computer uses a Central Processing Unit (CPU)
    to process input and produce output based on the
    instructions it has been given.
  • Random Access Memory (RAM) is used to store
    information currently in use. Including
  • Instructions.
  • Data from an Input Device waiting to be
    processed.
  • Processed data waiting to be sent to an Output
    Device.
  • Note Information may be loaded or may remain in
    memory even if it isnt going to be used.

15
Types of Languages
  • Machine Language
  • 110110010110
  • Nearly impossible to understand without reference
    books.
  • Assembly Language
  • ADD 1,2,3 Sum 2, 3, store in 1
  • Better than machine language, but still difficult
    to use.
  • High-Level Language
  • abc //Add b and c, store the sum in a
  • The code is more human readable more intuitive.
  • Each line of code may do the work of a few lines
    of code in assembly/machine language.

16
Java is High-Level
  • Machine language and assembly language are hard
    to code. You have to write programs in painfully
    low-level steps.
  • Java is high-level, so many tasks can be done
    using less code. This feature allows for programs
    to be written more quickly, and they are more
    readable.

17
Java is Multithreaded
  • Multithreading allows tasks to run in parallel.
  • A thread is an abstract task, so using the term
    multithreaded is similar to saying many-tasked.
  • Suppose I wanted to do the following
  • Run Anti-Virus program
  • Write a letter
  • Print the letter
  • Check email
  • Without multithreading, Id have to wait for the
    AV program to finish before starting my letter,
    and Id have to wait until the letter was done
    printing before I could check my email.

18
Java is Object Oriented
  • Java programs consist of Classes.
  • Classes are abstract representations of objects.
    They may contain attributes and operations.
  • A car could be represented by a class.
  • Class MyCar
  • Attributes (Fields)
  • Color
  • Horsepower
  • Operations (Methods)
  • Start Engine
  • Brake
  • Classes and attributes are nouns, operations are
    verbs.

19
Benefits of OOP
  • Classes encapsulate attributes and operations so
    that related things stay together.
  • You wouldnt want to try to use a cars brake
    method on a computer.
  • Or, use a bananas peel method on a car.
  • Or, set a cars horsepower field for a couch.

20
Benefits of OOP
  • Classes (and interfaces) can hide their internal
    components.
  • By keeping things private, the object can control
    who, what, and when certain things can happen.
  • Outsiders are only given access to certain
    methods.
  • Not usually given access to data fields
  • Methods can control getting and setting data
  • An interface is simply a list of requirements for
    a class.
  • An object can implement an interface.

21
Benefits of OOP
  • Object Oriented Programming (OOP) is intuitive.
  • Think about the objects involved in solving a
    problem and design the program around them.
  • Objects can be more specific versions, or
    extensions, of more general objects.
  • A convertible is a car.
  • A convertible has everything a car has and does
    everything a car can do, but it can also remove
    its roof.
  • Creating a general object makes defining a
    specific object easier.
  • You dont have to repeat all of the attributes
    and operations of a car when you define a
    convertible if youve already defined what a car
    is and that a convertible is a type of car.

22
OOP Terminology
  • Instantiation
  • Creating a new instance of an object.
  • I instantiate an instance of a car.
  • A car object has been instantiated.
  • An object cannot be used without first being
    instantiated.
  • I cant drive a car that is just a blueprint.
  • I need to build the car first!
  • Only classes, not interfaces, can be instantiated.

23
From Code to Program
  • Java Code is written using an Editor (emacs,
    pico, notepad, etc.) and saved to a file ending
    in .java.
  • emacs MyThing.java
  • A Compiler is used to translate Java code
    (contained in a .java file) into Bytecode, which
    is stored in a file ending in .class.
  • javac MyThing.java
  • Produces a file called MyThing.class
  • You may get compile-time errors here.
  • The compiler optimizes code.

24
From Code to Program
  • The program is executed (run) in the Java Virtual
    Machine (JVM) from the Bytecode.
  • java MyThing
  • Notice the absence of .class.
  • You may get run-time errors here.
  • To summarize, your code is compiled into an
    intermediate form (bytecode), which is then
    interpreted by the JVM specific to your Operating
    System (OS).
  • A program may be written on Linux, compiled in
    Windows, and run on a Mac using the JVM for Mac.
  • Some minor exceptions, but well ignore them.

25
Compile-Time Errors
  • Usually syntax errors.
  • Did you forget the semicolon () at the end of
    the line?
  • The compiler will mention the type of error and
    where it occurred.
  • Look on the line it reported, if you dont find
    an error there, look a line or two above and
    below that line.

26
Run-Time Errors
  • Exceptions may occur.
  • Follow the stack trace.
  • The methods and line numbers where the exception
    occurred will be printed to the console.
  • Use the same methodology as for a compile-time
    errors find out what happened, then fix the
    problem.
  • Go back through your logic and consider adding
    methods to handle invalid data, broken
    connections, and other previously overlooked
    opportunities for error.
  • Did you try to access data that you never
    created?
  • Remember to recompile!
  • Your changes wont be reflected in the bytecode
    that had the run-time error until you compile
    your updated version!

27
Logic Errors
  • Logic errors occur in programs that compile and
    run, but dont do what the programmer intended
    for them to do.
  • Logic errors usually dont get reported like
    compile-time or run-time errors do.
  • Always check your output to make sure it is
    correct.
  • Skim for unreasonable output if you dont want to
    check everything.
  • If my program should only produce output that
    contains numbers between 1 and 10, seeing a 42 is
    problematic.

28
Upcoming Topics
  • Datatypes/Objects
  • How data can be stored and modified safely.
  • Input/Output (I/O)
  • Getting input and sending output.
  • Conditionals
  • If a condition is met, do X, otherwise, do Y.
  • Loops
  • Do X a certain number of times.
  • Methods
  • Reusable code, like a form letter.
  • GUI Components
  • More interesting than text on the console.

29
Upcoming Topics
  • Arrays/Collections
  • Data grouped together, accessed by an index or
    key.
  • Inheritance
  • How specific objects relate to more general
    objects.
  • Polymorphism
  • How to write general programs that work in more
    than one case.
  • Searching Sorting
  • How to find data and store it in an orderly
    fashion
  • Applets
  • Java on the web! Simpler than youd expect
Write a Comment
User Comments (0)
About PowerShow.com