Savitch - PowerPoint PPT Presentation

1 / 23
About This Presentation
Title:

Savitch

Description:

Let's imagine that all officers get some allowance for uniforms. ... because I can invoke the calculate allowance for uniforms method without needing ... – PowerPoint PPT presentation

Number of Views:29
Avg rating:3.0/5.0
Slides: 24
Provided by: laurenc9
Category:
Tags: savitch | uniforms

less

Transcript and Presenter's Notes

Title: Savitch


1
1/13/2003
  • Savitch
  • Chapter One
  • And

2
Business
  • Reminders
  • Join the list
  • Submit information form
  • Submit permission to post
  • The forms are available on my web site

3
  • I think Ill start taking photos on today. Well
    see how it goes.
  • The syllabus now has links to web pages for the
    two texts

4
Chapter One
  • The stuff I dont mention, Im assuming you
    already know. If not,

5
Topics
  • Java Byte-Code 10-12
  • Object-Oriented Programming 17-23
  • 1.4 A Taste of Java 25-40

6
Java Byte-Code
  • It creates independence
  • If you have a Java Virtual Machine its
    software running on your computer, you can run a
    compiled Java program regardless of the type of
    machine on which it was compiled.
  • Thats a biggie

7
Interpreting
  • Actually the program runs on the JVM.
  • It is said to be interpreted.
  • The JVM interprets the byte code and does the
    equivalent work on the host machine

8
Object-Oriented Programming
  • See Dennis Wixon Chapter 16
  • There are things
  • Objects nouns
  • They do things to themselves or others
  • Methods verbs

9
  • Objects are a particular instance of a class
  • A class is like a blueprint for making objects
  • Objects have methods
  • The main method is often present, as on page 27
  • Objects may contain data

10
Three Design Principles
  • Encapsulation aka information hiding
  • Polymorphism
  • Inheritance
  • Ill do this second

11
Encapsulation
  • An object has
  • the right, the ability, the obligation (?)
  • to hide what is inside itself data and methods
    from the rest of the world. Why??
  • Control security safety
  • also flexibility

12
Flexibility ?
  • If the outside world cant see how the object
    works,it cant become aware of and then utilize
    that knowledge in ways that make it dependent on
    the implementation in the object. Because of
    this flexibility I can change the implementation
    way the object does things without a care that
    it will hurt those who use the object

13
Inheritance
  • A class, and the objects instantiated from that
    class, can either be done from scratch you would
    have assumed that or !!! thats emphasis they
    can be built upon a previously written class.
  • extended from and inherit from are synonyms
    for built upon

14
  • That means if I have a soldier class, I can
    extend it by writing a enlisted class and an
    officer class. The officer class can be extended
    to the various ranks and the same for the
    enlisted class. Each derived class will be based
    upon its super class. The particulars of the
    Lieutenant class will be written to either add to
    the basic class for an officer in case theres
    something that Lieutenants do that other officers
    dont or

15
  • Rewritten to reflect the ways in which a
    Lieutenant does the same thing but in a different
    manner.

16
Polymorphism
  • Lets imagine that all officers get some
    allowance for uniforms. It depends on their rank
    and years of service.
  • One could write a shared method for doing it.
    It would contain selection logic.
  • The problem is that the creation of a new rank
    would require going into the officer

17
  • class and modifying the selection logic. With
    inheritance, each class such as Lieutenant
    would have its own much simpler version of the
    calculation of the allowance for uniform
  • The creation of a new rank would necessitate the
    creation of a new class inherited from the
    officer class.
  • So!! Wheres the polymorphism?

18
  • The polymorphism comes in because I can invoke
    the calculate allowance for uniforms method
    without needing to know whether the object Im
    dealing with is a Lieutenant or a Captain or some
    other, perhaps new, rank.
  • It simplifies my coding that use officer
  • It simplifies maintenance

19
1.4 A Taste of Java
  • Applets later both in Ch. 1 and much later
  • Java application
  • Spelling rules
  • Compiling and Running

20
Applets
  • An applet is a java program that runs in a
    browser on the client side thats the user side
    its not the server side
  • We will look at Display 1.6 and 1.7 on pages 38
    39, later

21
Java Application
  • See page 27, Display 1.5

22
Spelling Rules
  • Java is case sensitive
  • VB is case insensitive
  • There are standards for when to capitalize
  • We will cover them later
  • There are keywords

23
Compiling and Running
  • These are more distinct activities than they were
    in VB
  • To compile without TextPad
  • or you can look at it as being what TextPad does
  • javac TheClass.java
  • This takes a .java file and makes a .class file
  • To run
  • java TheClass
Write a Comment
User Comments (0)
About PowerShow.com