Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fall 2005CSE 115/503 Introduction to Computer Science I1 Lecture #4 Agenda Announcements Review Questions? Classes and objects UML class diagrams Creating.

Similar presentations


Presentation on theme: "Fall 2005CSE 115/503 Introduction to Computer Science I1 Lecture #4 Agenda Announcements Review Questions? Classes and objects UML class diagrams Creating."— Presentation transcript:

1 Fall 2005CSE 115/503 Introduction to Computer Science I1 Lecture #4 Agenda Announcements Review Questions? Classes and objects UML class diagrams Creating objects (instantiating classes) Reminders Questions?

2 Fall 2005CSE 115/503 Introduction to Computer Science I2 Announcements Labs have been moved from Baldy 21 to Baldy 19. If you have an unofficial registration change, fill in form. Sign attendance sheet.

3 Fall 2005CSE 115/503 Introduction to Computer Science I3 Review Software development is an iterative and incremental process. OO software systems are systems of interacting objects. Objects have –properties –behaviors

4 Fall 2005CSE 115/503 Introduction to Computer Science I4 Where do objects come from? (The “birds and bees” lecture) Programmer writes a program in a high-level language like Java: MyApplet.java Computers don’t understand programs expressed in high- level languages  ?

5 Fall 2005CSE 115/503 Introduction to Computer Science I5 Compilation Programmer writes a program in a high-level language like Java: MyApplet.java A compiler translates program to an equivalent low-level form that a computer can understand MyApplet.class Compiler translates

6 Fall 2005CSE 115/503 Introduction to Computer Science I6 Runtime Compiler translates Runtime refers to the time during which a program is executing, or running.

7 Fall 2005CSE 115/503 Introduction to Computer Science I7 Objects exist only at runtime Compiler translates Objects exist only at runtime Objects do not exist while the programmer writes the program, except in their minds.

8 Fall 2005CSE 115/503 Introduction to Computer Science I8 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.

9 Fall 2005CSE 115/503 Introduction to Computer Science I9 So what are class definitions? A class definition is a description of the properties and behaviors that instances of the class will have. Recall that we said a running OO program is a system of interacting objects. Possible relationships between objects are determined by relationships between classes.

10 Fall 2005CSE 115/503 Introduction to Computer Science I10 UML class diagrams (1) UML = Unified Modeling Language We use only class diagrams, not other UML diagrams Purpose: –keep OO concepts separate from implementation language –operate at a more abstract level than programming language – avoid making implementation decisions when designing code

11 Fall 2005CSE 115/503 Introduction to Computer Science I11 UML class diagrams (2) Class box –Class name –Properties –Behaviors Only as much detail as is needed Relationships –inheritance –implements –composition –dependency –association

12 Fall 2005CSE 115/503 Introduction to Computer Science I12 Where do objects come from? Objects are instances of classes; We instantiate classes: –e.g.new BouncingBall() –There are three parts to this expression: new BouncingBall ()

13 Fall 2005CSE 115/503 Introduction to Computer Science I13 new BouncingBall() ‘new’ is a “reserved word” in Java. This means that the word ‘new’ has a special meaning in the Java language. ‘new’ is the name of an operator whose job it is to create an instance of a given class BouncingBall is the name of a constructor of the BouncingBall class. A constructor initializes the state of a newly created object. The parentheses delimit the argument list of the constructor call. In this case there are no arguments being passed along to the constructor, so the argument list is empty.


Download ppt "Fall 2005CSE 115/503 Introduction to Computer Science I1 Lecture #4 Agenda Announcements Review Questions? Classes and objects UML class diagrams Creating."

Similar presentations


Ads by Google