Study Note - Introduction to Software Design | CS 1114, Study notes of Computer Science

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

Pre 2010

Uploaded on 02/28/2010

ryanlivolsi
ryanlivolsi 🇺🇸

9 documents

1 / 10

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 1114: Introduction to
Software Design
Object
BlueJ
Specialization
http://moodle.cs.vt.edu/
BlueJ
Godmar Back
gback@cs vt edu
gback@cs
.
vt
.
edu
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Study Note - Introduction to Software Design | CS 1114 and more Study notes Computer Science in PDF only on Docsity!

CS 1114: Introduction to

Software Design Object

BlueJ

Specialization

http://moodle.cs.vt.edu/

BlueJ

Godmar Backgback@cs vt [email protected]

Distinguished Lecture - Ubiquitous Care: Casestudies in human-centered technology forhealth and educationGregory D. Abowd Georgia Tech L^

ti

T

L

ocation:

T

orgersen 2160

Date:

Friday, February 19, 2010

Time:

11:15am-12:30pm

A M

t th

S

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)

Recap: Overloading

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

Control Flow

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

Substitution and Subtyping

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”

Example Interfaces

// Role R interface

R {

// Role Q interface

Q {

interface

R {

void ability1();void ability2();

interface

Q {

void ability1();void ability3();

} class

A implements R {

} class

B implements R, Q {

p^

void ability1() { … code … }void ability2() { … code … } }

p^

, Q {

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

A Simple Persistent Store student.web.Application

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() { … }