CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall NEW  645-4739  NEW 1.

Slides:



Advertisements
Similar presentations
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
Advertisements

CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
Primitive Data Types There are a number of common objects we encounter and are treated specially by almost any programming language These are called basic.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
Lecture #3 – Agenda Cell phones off & name signs out –I’ll judge signs on Wednesday next week Quick review & Questions Activity Problem solving.
CSE116: Introduction to Computer Science 2 Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
Lecture #5 Agenda Cell phones off & name signs out Review Questions? UML class diagram introduction Our first class definition!
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall 1.
Syntax & terminology review While the following slides are not exactly what we did on the board (object diagrams are not shown here) they cover most of.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall 1.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE111: Great Ideas in Computer Science Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
Arrays. Memory organization Table at right shows 16 bytes, each consisting of 8 bits Each byte has an address, shown in the column to the left
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall 1.
CSE111: Great Ideas in Computer Science Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE111: Great Ideas in Computer Science Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE111: Great Ideas in Computer Science Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall 1.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE 115 / 503 Introduction to Computer Science I
CSE 115 / 503 Introduction to Computer Science For Majors I Carl Alphonce 219 Bell Hall.
Lecture #4 Agenda Cell phones off & name signs out Review Questions? Objects The birds-and-the-bees talk.
Fall 2005CSE 115/503 Introduction to Computer Science I1 Lecture #4 Agenda Announcements Review Questions? Classes and objects UML class diagrams Creating.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE 115 / 503 Introduction to Computer Science For Majors I Carl Alphonce 219 Bell Hall.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall
Introduction to Computers and Programming. Some definitions Algorithm: Algorithm: A procedure for solving a problem A procedure for solving a problem.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall
CSE 116 Introduction to Computer Science For Majors II Carl Alphonce 219 Bell Hall.
1 CSC 1401 S1 Computer Programming I Hamid Harroud School of Science and Engineering, Akhawayn University
CMPT 120 How computers run programs Summer 2012 Instructor: Hassan Khosravi.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall NEW   NEW 1.
CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall 1.
CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall 1.
Session One Introduction. Personal Introduction Role of programmers Robot Examination HUD & HID Uploading Code.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall
Lecture 2 Object Oriented Programming Basics of Java Language MBY.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall
C Programming Pointers
Introduction to Computer Science
Presentation transcript:

CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall NEW   NEW 1

Agenda Cell phones off & name signs out Review Questions? Objects The birds-and-the-bees talk Communicating with objects

Review Software development is an iterative and incremental process. OO software systems are systems of interacting objects. Objects have –properties: things objects know (think of the counting object last class) –behaviors: things objects do (think of the “jumping jack” object)

How do we create objects? –new example1.Terrarium() –There are three parts to this expression: new example1.Terrarium ()

Let’s try it! We use a tool called Eclipse… …and a plug-in for Eclipse called DrJava DrJava provides an interactions pane

Eclipse tour terminology –view: a subwindow in Eclipse –perspective: a collection of views Eclipse: a framework for building tools –Eclipse is extended via plug-ins –a plug-in: Java Development Tools (JDT) –others: DrJava, Green, CDT, …

Expression evaluation evaluating new example1.Terrarium() –causes an object to be created and initialized –produces a value

(part of) memory

evaluating a ‘new’ expression used available used When evaluating an expression like ‘new example1.Terrarium()’, the operator ‘new’ first determines the size of the object to be created (let us say it is four byte for the sake of this example)

evaluating a ‘new’ expression used reserved by ‘new’ available used When evaluating an expression like ‘new example1.Terrarium()’, the operator ‘new’ first determines the size of the object to be created (let us say it is four byte for the sake of this example) Next, new must secure a contiguous block of memory four bytes large, to store the representation of the object.

evaluating a ‘new’ expression used available used When evaluating an expression like ‘new example1.Terrarium()’, the operator ‘new’ first determines the size of the object to be created (let us say it is four byte for the sake of this example) Next, new must secure a contiguous block of memory four bytes large, to store the representation of the object. Bit strings representing the object are written into the reserved memory locations.

evaluating a ‘new’ expression used available used When evaluating an expression like ‘new example1.Terrarium()’, the operator ‘new’ first determines the size of the object to be created (let us say it is four byte for the sake of this example) Next, new must secure a contiguous block of memory four bytes large, to store the representation of the object. Bit strings representing the object are written into the reserved memory locations. The starting address of the block of memory holding the object’s representation is the value of the ‘new’ expression. This address is called a ‘reference’.

evaluating a ‘new’ expression A similar thing happens when we evaluate another ‘new’ expression like ‘new example1.Caterpillar()’. used available used

available used evaluating a ‘new’ expression A similar thing happens when we evaluate another ‘new’ expression like ‘new example1.Caterpillar()’. Supposing that an example1.Caterpillar object occupies two bytes of memory, new reserves a contiguous block of two bytes, writes bit strings representing the object to those memory locations, and the starting address of this block of memory is the value of the ‘new’ expression.

DrJava’s response When we evaluate these ‘new’ expressions in DrJava, what is the response we get? > new example1.Terrarium() example1.Terrarium[frame0,0,0,608x434,layout=java.awt.BorderLayout,tit le=,resizable,normal,defaultCloseOperation=EXIT_ON_CLOSE,rootPane=j avax.swing.JRootPane[,4,30,600x400,layout=javax.swing.JRootPane$Roo tLayout,alignmentX=0.0,alignmentY=0.0,border=,flags= ,maximu mSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true] > new example1.Caterpillar()

DrJava’s response These responses don’t look like memory addresses. What’s going on? After DrJava evaluates the expression, it must print the value. The way Java works when a reference is printed a textual representation of the object it refers to is produced (as defined by the object itself)

We’ve seen how to create an object. But where does the object come from? How does DrJava know what an example1.Terrarium() object is? Where do objects come from? (The “birds and bees” lecture)

Object communication To put example1.Caterpillar object example1.Terrarium object: > new example1.Terrarium().add(new example1.Caterpillar())

Where do objects come from? (The “birds and bees” lecture) Programmer writes a program in a high-level language like Java: example1.Terrarium.java Computers don’t understand programs expressed in high-level languages  ?

Compilation A compiler translates program to an equivalent low-level form that a computer can understand example1.Terrarium.class Compiler translates Programmer writes a program in a high-level language like Java: example1.Terrarium.java

Runtime Runtime refers to the time during which a program is executing, or running. Compiler translates

Objects exist only at runtime Objects do not exist while the programmer writes the program, except in their minds. Compiler translates

Huh? If objects are the basic building blocks of object-oriented programs, and programmers don’t directly manipulate objects, what do programmers write? They write class definitions. Objects are instances of classes. Classes are instantiated only at runtime.