






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Professor: Back; Class: Intro to Software Design; Subject: Computer Science; University: Virginia Polytechnic Institute And State University; Term: Spring 2010;
Typology: Study notes
1 / 10
This page cannot be seen from the preview
Don't miss anything!







BlueJ
Specialization
http://moodle.cs.vt.edu/
BlueJ
Godmar Backgback@cs vt [email protected]
ti
ocation:
orgersen 2160
Date:
Friday, February 19, 2010
Time:
11:15am-12:30pm
t th
k^
i^
ill b
A Meet-the-Speaker session will beheld 4:00pm-5:30pm in McBryde 106.
Sponsored by the Department of Computer Science and theCenter for Human Computer Interaction (CHCI)
Relationship between methods of a class with the same
name
but different signatures
name, but different signatures- or between constructors Resolved at compile-time:
Destination of call depends on (declared) types ofparametersparameters Use only if each version of the method really does
substantially the same thing
Java supports classic control flow constructs
inherited from C family of languagesinherited from C family of languages “if”/”else” statements
“for” loops“while” loops“do-while” loops“switch” statements
With inheritance, every object can be substituted wherever an object of
any of its superclasses is expected
y^
p^
p
But each object can have only one superclass!Too limiting. Would like to declare additional
roles an object can play –
as many as required in a program
f^
h^
d^
b
l^
ll^
b^
l
Use interfaces: types that describe
roles, allowing objects to act in a role
Consist of a set of method names + signaturesTo act in role R, you must be able to perform duties f1, f2, f3Cl
i^
id t
“i^
l^
t i t
f^
R”
Class is said to “implement interface R”
// Role R interface
// Role Q interface
interface
void ability1();void ability2();
interface
void ability1();void ability3();
} class
A implements R {
} class
B implements R, Q {
p^
void ability1() { … code … }void ability2() { … code … } }
p^
void ability1() { … code … }void ability2() { … code … }void ability3() {
code
}^ Class can implement multiple interfaces, thus can be used in
void ability3() { … code … } }
p^
p
any context that expects any of the “roles” it can perform
maintains current user and
getSharedObject
maintains current user andsupports access topersistent state
getSharedObject
Sh
dObj
“Abstract” class
Missing a ‘login()’ method –
setSharedObject
Missing
a login() method
you complete the classby extending it
Application
setSharedObject() {…}getSharedObject() {…}abstract login();abstract login();
FaceBooklet
FaceBooklet
OtherApplication
student
student
setSharedObjectgetSharedObjectlogin() { … }
setSharedObjectgetSharedObjectlogin() { … }
setSharedObjectgetSharedObjectlogin() { … }