CSCI111: Chapter 1 Part 2

CSCI 111: Chapter 1 (1.4 - 1.6)


Course Focus: Object-Oriented Programming (OOP)

Some Java Specifics

slide 43-47 and code for slide 45, 52

I have put some of this sections material into my Chapter 2 notes since I think it fits there better.

Program Development

slide 54-55 Programs are sequences of instructions - they can be large or small

Algorithms are the "recipes" ... the sequence of steps to achieve the desired goal.

All algorithms are made up of:

When we write these we call it source code and it is (hopefully) readable by others.
The machine takes our source code and puts it into a form that it can understand. How?      slide 56

One reason that Java was so cool was that it was platform-independent (discuss byte code again) slide 57-58

Integrated Development Environments

Some people like to use tools to help them organize their programs: slide 59
  • Object Modeling Tools more on these later

    Learning a Language

    No matter what tools we have to help us, we still need to make sure that what we write is understandable by the compiler so it can translate it.
    And we need to make sure that we write what we mean slide 60

    Programs are written in languages that have synax and semantics (like any other language)

    Programs often have errors - three different kinds!.     slide 61

    Operating Systems

    The programs need to run on something - and something has to tell the machine what it is supposed to do when.

    Operating Systems are the programs that "operate" the machine - tell it what to do.

    This is actually very cool. slide 9

    Files

    careful with slashes:
    forward (/)on Unix
    backward (\)on Microsoft

    ls -F
    to distinguish between files and directories(folders) in UNIX

    For more see the UNIX part of the machines and java notes in Getting Started

    Editors

    See also the UNIX Editors in Getting Started Facilities to:

    Basic Program Development: Software Principles

    slide 64 Problem Solving
    1. Analysis
    2. Design
    3. Write (Implement)
    4. Compile
    5. Test (Run application or browse applet)
    THEN repeat until works (i.e, DEBUGGING ) slide 62 (software models: waterfall vs fountain)

    Whenever you have problems with code and want to ask anyone for help (whether it be lab assistant, TA, instructor, local UNIX guru, local Java guru, friend, etc.) you should always send a copy of your error message with your request for help. To just say it "doesn't work" does not help us to help you. (1) Tell us what you did and (2) Give us the compiler or run-time error so we have some clue of the problem

    On the Web?

    You need an HTML file with the applet tag to put your java applet on the web. See Lab1 for your first example... you used index.html or lab1.html to put the applet tag

    Course Focus: Object-Oriented Programming (OOP)

    slide 65-71
    Objects

    Classes an abstract grouping of objects of the same type

    Instances a specific individual object of a class (new)

    Inheritance allows code reuse (a wonderful thing)

    Again...remember to look at slide 65-71

    Libraries

    imports
    allow run-time linking to needed classes

    Here is a copy of The Java API and an API users guide and also the Tool Reference page will be most helpful

    Running the program

    Run application (from command line ) by calling (notice no extension)
    java filename
    OR applet using Appletviewer (notice in tools page) or browsers
    appletviewer http://www.pagetutor.com/idiot/idiot.html
    is a cute one to try, or your own (in both, notice use of extension .html)
    appletviewer http://www.ecst.csuchico.edu/~yourname/HelloWorld.html

    Demystifying the program

    Consider a program like your lab 1. The line numbers are there so I can discuss the lines, they would not be in your code. 1. import java.awt.*; 2. import java.applet.Applet; 3. public class Greeting extends Applet { 4. public void paint(Graphics g) { 5. g.drawString("Hello", 50, 50); 6. } 7. } First, from the java.awt package, a look at the Graphics Class      and its drawString method

    OK, you fill in what each line is all about...

    1. .
    2. .
    3. .
    4. .
    5. .
    6. note indentation
    7. .
    Hint on number 5: Question in class, "What is 50,50 for?"
    50 pixels from left of screen and 50 pixels from top (x,y position)

    What should this file be called? (also see the Swing Version )

    What else do I need to do after writing it?

    here it is (note how to look at its source from the web page)


    A copy of the text author's slides used in the lecture.