成果java程序設(shè)計(jì)-lecture_第1頁
成果java程序設(shè)計(jì)-lecture_第2頁
成果java程序設(shè)計(jì)-lecture_第3頁
成果java程序設(shè)計(jì)-lecture_第4頁
成果java程序設(shè)計(jì)-lecture_第5頁
免費(fèi)預(yù)覽已結(jié)束,剩余25頁可下載查看

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

12-2ObjectivesProcess

of

program

developmentIntroduction

to

Java

ProgrammingRelationship

types:

association,

aggregation,strong

inheritance,

and

weak

inheritanceClasses

and

systems

designing12-3Software

Development

ProcessRequirementSpecificationSystemysisSystemDesignTestingImplementationMaintenanceDeploymentIntroduction

to

Java

Programming12-4Requirement

SpecificationRequirementSpecificationSystemysisSystemDesignTestingImplementationMaintenanceDeploymentA

formal

process

that

seeks

tounderstand

the

problem

andin

detail

what

thesoftware

system

needs

to

do.

Thisphase

involves

close

interactionbetween

users

and

designersIntroduction

to

Java

Programming12-5Example:EMall目標(biāo):要構(gòu)建的是一個會員制虛擬購物中心需求分析:–用戶需要,登錄后方可進(jìn)入本“購物中心”。

時需提供用戶名、、個人基本信息及賬戶號碼。用戶注冊時可以選擇是否作為店主經(jīng)營一家,如不選擇作為店主,即成為普通購物者用戶;如選擇作為店主,除須填寫以上信息外,還需填上申請的名、信息,完成后產(chǎn)生一個新的

。用戶完成后,即可通過登陸進(jìn)入購物中心。–用戶在登錄時使用用戶名和

。購物者登錄后即進(jìn)入大廳,大廳類應(yīng)顯示正在經(jīng)營的和關(guān)閉狀態(tài)的,購物者只能進(jìn)入正在經(jīng)營的

。店主登錄時可選擇是否以店主方式登錄,若以店主方式登錄,則進(jìn)行該店商品的管理工作,而不能進(jìn)行任何購物活動;否則,作為普通購物者進(jìn)入大廳。Introduction

to

Java

Programming12-6Example:EMall需求分析(續(xù)):–購物者在大廳中選擇進(jìn)入選購商品。用戶進(jìn)入后,選定希望的商品,把一定數(shù)量的商品以相應(yīng)的價(jià)格加入購物車中,中相應(yīng)商品的數(shù)量(暫時)予以扣除。購物者在退出購物中心之前,可確認(rèn)并支付購買商品。當(dāng)購物者確認(rèn)商品后,需通知服務(wù)器,服務(wù)器將對購物者和店主的賬戶余額進(jìn)行調(diào)整,然后將本次的信息記入作為購物歷史信息。

之前放棄購物車中的任何商品,放棄者可在確認(rèn)將使得店鋪中的相應(yīng)商品數(shù)量恢復(fù)。–

者退出大廳之前,檢查購物車,如其中沒有未商品,即退出系統(tǒng)。店主退出系統(tǒng)時,其經(jīng)營

即關(guān)閉。Introduction

to

Java

Programming12-7SystemysisRequirementSpecificationSystemysisSystemDesignTestingImplementationMaintenanceDeploymentSeeks

to yze

the

businessprocess

in

terms

of

data

flow,

andto

identify

the

system’s

input

andoutputPart

of

the ysis

entails

modelingthe

system’s

behavior.

The

model

isintended

to

capture

theessentialelements

of

the

system

and

to

defineservices

to

the

systemIntroduction

to

Java

Programming12-8Example:EMall系統(tǒng)分析:–用戶…–【用戶】分析和登錄用戶需要,登錄后方可進(jìn)入本“購物中心”。時需提供:用戶名(用戶名唯一)、

、個人基本信息以及(虛擬)賬戶號碼,并可以選擇

為一般購物者還是店主,店主除須填寫以上信息外,還需填上申請的

名(唯一),

信息。登錄時使用用戶名和

登錄。Introduction

to

Java

Programming12-9Example:EMall系統(tǒng)分析:–【用戶】分析(續(xù))用戶分類{店主}:店主在時需要向服務(wù)器創(chuàng)建

,登錄時需選擇以一般購物者方式還是店主方式登入。若以店主方式登錄,則進(jìn)行該店商品的管理工作,如開門營業(yè),打烊,修改自己的商品標(biāo)價(jià),數(shù)量以及增添商品等等,而不能進(jìn)行任何購物活動。另外店主在退出之前還應(yīng)保留本的信息至本地文件,在下次登錄時無須和服務(wù)器交互,直接從本地載入。{購物者}:購物者登錄后即進(jìn)入大廳,并且只能進(jìn)入正在經(jīng)營的

。

者選定商品后,加入購物車。購物者可以操作購物車,即放棄或確認(rèn)某次交易。Introduction

to

Java

Programming12-10Example:EMall系統(tǒng)分析:–【用戶】分析(續(xù))商品

流程用戶進(jìn)入

后,選定希望的商品,將一定數(shù)量的商品以相應(yīng)的價(jià)格加入購物車中,品的數(shù)量(暫時)予以扣除。(店主與中相應(yīng)商者的交互最好做成客戶端之間直接的通信,以減輕服務(wù)器的負(fù)擔(dān))購物者在退出購物中心之前,確認(rèn)并支付商品。如果購物者在支付之前掉線,購物車中的商品即之前放棄購中的相應(yīng)商算全部放棄,者亦可在確認(rèn)物車中的任意商品,放棄將使得品數(shù)量恢復(fù)。Introduction

to

Java

Programming12-11System

DesignRequirementSpecificationSystemysisSystemDesignTestingImplementationMaintenanceDeploymentThe

process

of

designing

thesystem’s

components.This

phase

involves

the

use

of

manylevels

of ion

to

posethe

problem

into

manageablecomponents,

identify

classes

andinterfaces,

and

establishrelationships

among

the

classes

andinterfaces.Introduction

to

Java

Programming12-12Example:EMall系統(tǒng)設(shè)計(jì):–【用戶】{用戶基類User}User類作為用戶基類,是客戶端,應(yīng)為類。其中應(yīng)提供用戶

(register)、登錄(login)、注銷(logout)以及查看賬戶余額,賬戶充值,賬戶扣除金額等方法,其子類Customer和Owner類應(yīng)重載這些方法。{購物者類Customer}Customer類繼承User類。除重載User類方法外,需提供將商品加入購物車(addMerchandise)和從購物車中取出(removeMerchandise)方法,以及支付方法(buy)等。Introduction

to

Java

Programming12-13Example:EMall系統(tǒng)設(shè)計(jì):–【用戶】(續(xù)){店主類Owner}Owner類繼承User類。除重載User類方法外,需提供一組用來管理對應(yīng)

的方法,如修改商品信息(包括數(shù)量,價(jià)格)(modify)方法,添加新的商品(addMerchandise)方法,刪除商品(deleteMerchandise)方法等。用戶在確認(rèn)

后,店主應(yīng)調(diào)整相應(yīng)的商品數(shù)量及賬戶金額。Introduction

to

Java

Programming12-14ImplementationRequirementSpecificationSystemysisSystemDesignImplementationMaintenanceDeploymentThis

phase

requires

the

use

ofaprogramming

language

like

Java.The

implementation

involvescoding,

testing,

and

debuggingTestingThe

process

of

translating

thesystem

design

into

programs.Separate

programsare

written

foreach

component

andput

to

worktogether.Introduction

to

Java

Programming12-15TestingRequirementSpecificationSystemysisSystemDesignTestingImplementationMaintenanceDeploymentEnsures

that

the

code

meets

therequirements

specification

andweeds

out

bugs.An

independent

team

of

softwareengineers

not

involved

in

the

designand

implementation

of

the

projectusually

conducts

suchtestingIntroduction

to

Java

Programming12-16DeploymentRequirementSpecificationSystemysisSystemDesignTestingImplementationMaintenanceDeploymentDeployment

makes

the

projectavailable

foruse.For

a

Java

applet,

this

meansinstalling

it

on

a

Web

server;

foraJava

application,

installing

it

on

theclient's

computer.Introduction

to

Java

Programming12-17MaintenanceRequirementSpecificationSystemysisSystemDesignTestingImplementationMaintenanceDeploymentMaintenance

is

concerned

withchanging

and

improving

theproduct.A

software

product

must

continue

toperform

and

improve

in

a

changingenvironment.

This

requires

periodicupgrades

of

the

product

to

fixnewlydiscovered

bugs

and

incorporatechanges.Introduction

to

Java

Programming12-18Relationships

among

ClassesIntroduction

to

Java

ProgrammingAssociationAggregationCompositionDependenceInheritance12-19AssociationAssociation

represents

a

general

binary

relationship

thatdescribes

an

activity

between

two

classes.Student5..60

TakeCourse0..3

Teach

1FacultyTeacherpublic

class

Student

{/**

Data

fields

*/private

Course[]courseList;/**

Constructors

*//**

Methods

*/}Introduction

to

Java

Programmingpublic

class

Course

{/**

Data

fields

*/private

Student[]classList;private

Faculty

faculty/**

Constructors

*//**

Methods

*/}public

class

Faculty

{/**

Data

fields

*/private

Course[]courseList;/**

Constructors

*//**

Methods

*/}An

association

is

usually

represented

as

a

data

field

or

method

in

the

class.12-20Aggregation

and

CompositionAggregation

is

a

special

form

of

association,

whichrepresents

an

ownership

relationship

between

twoclassesAggregation

models

the

has-a

relationshipIf

an

object

is

exclusively

owned

by

an

aggregatedobject,

the

relationship

between

the

object

and

itsaggregated

object

is

referred

to

as

composition.NameAddressCompositionIntroduction

to

Java

ProgrammingAggregation12-21Representing

Aggregation

in

ClassesAn

aggregation

relationship

is

usually

represented

as

adata

field

in

the

aggregated

class.public

class

Name

{/**

Data

fields

*//**

Constructors

*//**

Methods

*/}public

class

{/**

Data

fields

*/private

Name

name;private

Address

address;/**

Constructors

*//**

Methods

*/}public

class

Address

{/**

Data

fields

*//**

Constructors

*//**

Methods

*/}Introduction

to

Java

Programming12-22Inner

Classes

Translationclass

only,.

ForIf

Name

or

Address

is

used

in

thethey

can

be

declared

as

an

inner

class

inexample:publicclass

{private

Name

name;private

Address

address;...class

Name

{...}class

Address

{...}Introduction

to

Java

Programming}12-23InheritanceInheritance

models

the

is-a

relationship

betweentwo

classes.Introductionto

Java

ProgrammingFacultypublic

class

Student

extends/**

Data

fields

*//**

Constructors

*//**

Methods

*/}(B){(A)12-24Weak

Inheritance

RelationshipA

weak

is-a

relationship

can

be

represented

using

interfacesFor

example,

the

weak

is-a

relationship

“students

arecomparable

based

on

their

grades”

can

be

represented

byimplementing

the

Comparable

interface,

as

follows:public

class

Student

extendsStudentComparableimplements

Comparable

{/**

Data

fields,

Constructors,

and

*//**

Methods

*//**

Implement

the

compareTo

method

*/public

int

compareTo(Object

object)

{//

...}}(A)(B)Introduction

to

Java

Programming12-25Class

DesignIntroductionto

Java

ProgrammingMethodClassionionSteps

of

building

an

object-oriented

system:Identify

classes

for

the

systemDescribe

attributes

and

methods

in

each

classEstablish

relationships

among

classesCreate

classes12-26Class

Design

GuidelinesIntroduction

to

Java

ProgrammingDesigning

a

Single

ClassUsing

Modifiers

public,

protected,

private

and

packageUsing

Inheritance

or

CompositionUsing

Interfaces

or

Classes12-27Designing

aClassIntroduction

to

Java

ProgrammingA

class

should

describe

a

single

entity

or

a

set

ofsimilar

operations.

A

single

entity

with

too

manyresponsibilities

can

be

broken

into

several

classes

toseparate

responsibilitiesClasses

are

usually

designed

for

use

by

manydifferent

customersClasses

are

designed

for

reuseProvide

a

public

no-arg

constructor

and

overridethe

equals

method

and

the

toString

method

definedin

the

Object

class

whenever

possibleFollow

standard

Java

programming

style

andnaming

conventions12-28Using

Visibility

ModifiersEach

class

can

present

two

contracts

one

for

theusers

of

the

class

and

one

for

the

extenders

of

theclassMake

the

fields

private

and

accessor

methods

publicif

they

are

intended

for

the

users

of

the

classMake

the

fields

or

method

protected

if

they

areintended

for

extenders

of

the

classThe

extended

class

may

increase

the

visibility

of

aninstance

method

from

protected

to

public,

or

changeits

implementationA

classshould

also

hide

methods

not

intended

forclient

useIntroduction

to

Java

Programming12-29Using

the

static

ModifierIntroduction

to

Java

ProgrammingA

property

that

is

shared

by

all

the

instances

of

theclass

should

be

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論