• 沒有找到結果。

OOP with Java

N/A
N/A
Protected

Academic year: 2022

Share "OOP with Java"

Copied!
11
0
0

加載中.... (立即查看全文)

全文

(1)

OOP with Java

Hsuan-Tien Lin

Deptartment of CSIE, NTU

OOP Class, April 28, 2009

H.-T. Lin (NTU CSIE) OOP with Java OOP(even) 04/28/2009 0 / 10

(2)

One Common Suggestion

Can we BE more OOP?

Sure, but what do you want to learn?

H.-T. Lin (NTU CSIE) OOP with Java OOP(even) 04/28/2009 1 / 10

(3)

My View about the Course

How to use Java to realize OOP?

abstract OOP thinking: UML concrete OOP realization: Java

H.-T. Lin (NTU CSIE) OOP with Java OOP(even) 04/28/2009 2 / 10

(4)

But More...

How to use Java to realize OOP &

to write programs?

a modern and useful 1st language: C a modern and useful 2nd language: Java

H.-T. Lin (NTU CSIE) OOP with Java OOP(even) 04/28/2009 3 / 10

(5)

Our Past Focus: the Common Part

How to use Java to realize OOP &

to write programs?

the mechanism within a language (and the platform) almost your only chance because there is no PL class now

H.-T. Lin (NTU CSIE) OOP with Java OOP(even) 04/28/2009 4 / 10

(6)

The Missing Part, OOP-Wise

how does one design good OOP program (emphasized in recent homeworks)?

how does the mechanism relate to OOP?

Let’s go with a bigger picture.

H.-T. Lin (NTU CSIE) OOP with Java OOP(even) 04/28/2009 5 / 10

(7)

The Java Mechanism to Abstraction (1/2)

abstraction

the ability to express and manipulate objects class for blueprint (as the “class” file)

instance for individual objects (in memory)

reference (a.k.a. type-safe pointer) for the “handle” of object object lifecycle: from constructor to finalizer

H.-T. Lin (NTU CSIE) OOP with Java OOP(even) 04/28/2009 6 / 10

(8)

The Java Mechanism to Abstraction (2/2)

abstraction

the ability to express and manipulate objects data (a.k.a. memory interpretation):

important for program designers

not so important for component users (see encapsulation) action (a.k.a. method invocation): pass in this for

instance-specific actions

H.-T. Lin (NTU CSIE) OOP with Java OOP(even) 04/28/2009 7 / 10

(9)

The Java Mechanism to Composition

composition

the ability to play and interact with objects didn’t emphasize it, but naturally just used it

object accessing scheme (use existing classes through static/instance/local variables)

—again, object lifecycle

action invocation scheme (stack frame, parameter passing, and return value)

—again, instance-specific (and independent) actions

H.-T. Lin (NTU CSIE) OOP with Java OOP(even) 04/28/2009 8 / 10

(10)

The Java Mechanism to Inheritance

inheritance

the ability to extend objects type compatibility

—hierachy in a full-OO language

same reference, compatible types, how?

—possibly, shared prefix mechanism same reference, overridden actions, how?

—will talk more in polymorphism

H.-T. Lin (NTU CSIE) OOP with Java OOP(even) 04/28/2009 9 / 10

(11)

The Java Mechanism to Encapsulation

encapsulation the ability to “pack” objects as an advanced abstraction

—safer (and more clear) to be “public” only when necessary language/platform support for different access levels

H.-T. Lin (NTU CSIE) OOP with Java OOP(even) 04/28/2009 10 / 10

參考文獻

相關文件

• The memory storage unit is where instructions and data are held while a computer program is running.. • A bus is a group of parallel wires that transfer data from one part of

– The The readLine readLine method is the same method used to read method is the same method used to read  from the keyboard, but in this case it would read from a 

(4) (80%) Implement the data structure you designed and write a demo program (with the input/out- put format) to show how your data structure performs the five desired actions..

– Programming methodology that views a program  as consisting of objects that interact with one

• The memory storage unit holds instructions and data for a running program.. • A bus is a group of wires that transfer data from one part to another (data,

- [ Configuration Properties > Microsoft Macro Assembler > General > Include Paths ]. • Enter the paths to your

• The Java programming language is based on the virtual machine concept. • A program written in the Java language is translated by a Java compiler into Java

[r]