成果java程序设计-lecture_第1页
成果java程序设计-lecture_第2页
成果java程序设计-lecture_第3页
成果java程序设计-lecture_第4页
成果java程序设计-lecture_第5页
已阅读5页,还剩25页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

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目标:要构建的是一个会员制虚拟购物中心需求分析:–用户需要,登录后方可进入本“购物中心”。

时需提供用户名、、个人基本信息及账户号码。用户注册时可以选择是否作为店主经营一家,如不选择作为店主,即成为普通购物者用户;如选择作为店主,除须填写以上信息外,还需填上申请的名、信息,完成后产生一个新的

。用户完成后,即可通过登陆进入购物中心。–用户在登录时使用用户名和

。购物者登录后即进入大厅,大厅类应显示正在经营的和关闭状态的,购物者只能进入正在经营的

。店主登录时可选择是否以店主方式登录,若以店主方式登录,则进行该店商品的管理工作,而不能进行任何购物活动;否则,作为普通购物者进入大厅。Introduction

to

Java

Programming12-6Example:EMall需求分析(续):–购物者在大厅中选择进入选购商品。用户进入后,选定希望的商品,把一定数量的商品以相应的价格加入购物车中,中相应商品的数量(暂时)予以扣除。购物者在退出购物中心之前,可确认并支付购买商品。当购物者确认商品后,需通知服务器,服务器将对购物者和店主的账户余额进行调整,然后将本次的信息记入作为购物历史信息。

之前放弃购物车中的任何商品,放弃者可在确认将使得店铺中的相应商品数量恢复。–

者退出大厅之前,检查购物车,如其中没有未商品,即退出系统。店主退出系统时,其经营

即关闭。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系统分析:–用户…–【用户】分析和登录用户需要,登录后方可进入本“购物中心”。时需提供:用户名(用户名唯一)、

、个人基本信息以及(虚拟)账户号码,并可以选择

为一般购物者还是店主,店主除须填写以上信息外,还需填上申请的

名(唯一),

信息。登录时使用用户名和

登录。Introduction

to

Java

Programming12-9Example:EMall系统分析:–【用户】分析(续)用户分类{店主}:店主在时需要向服务器创建

,登录时需选择以一般购物者方式还是店主方式登入。若以店主方式登录,则进行该店商品的管理工作,如开门营业,打烊,修改自己的商品标价,数量以及增添商品等等,而不能进行任何购物活动。另外店主在退出之前还应保留本的信息至本地文件,在下次登录时无须和服务器交互,直接从本地载入。{购物者}:购物者登录后即进入大厅,并且只能进入正在经营的

者选定商品后,加入购物车。购物者可以操作购物车,即放弃或确认某次交易。Introduction

to

Java

Programming12-10Example:EMall系统分析:–【用户】分析(续)商品

流程用户进入

后,选定希望的商品,将一定数量的商品以相应的价格加入购物车中,品的数量(暂时)予以扣除。(店主与中相应商者的交互最好做成客户端之间直接的通信,以减轻服务器的负担)购物者在退出购物中心之前,确认并支付商品。如果购物者在支付之前掉线,购物车中的商品即之前放弃购中的相应商算全部放弃,者亦可在确认物车中的任意商品,放弃将使得品数量恢复。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系统设计:–【用户】{用户基类User}User类作为用户基类,是客户端,应为类。其中应提供用户

(register)、登录(login)、注销(logout)以及查看账户余额,账户充值,账户扣除金额等方法,其子类Customer和Owner类应重载这些方法。{购物者类Customer}Customer类继承User类。除重载User类方法外,需提供将商品加入购物车(addMerchandise)和从购物车中取出(removeMerchandise)方法,以及支付方法(buy)等。Introduction

to

Java

Programming12-13Example:EMall系统设计:–【用户】(续){店主类Owner}Owner类继承User类。除重载User类方法外,需提供一组用来管理对应

的方法,如修改商品信息(包括数量,价格)(modify)方法,添加新的商品(addMerchandise)方法,删除商品(deleteMerchandise)方法等。用户在确认

后,店主应调整相应的商品数量及账户金额。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. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论