OO实例教学课件_第1页
OO实例教学课件_第2页
OO实例教学课件_第3页
OO实例教学课件_第4页
OO实例教学课件_第5页
已阅读5页,还剩41页未读 继续免费阅读

下载本文档

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

文档简介

WhatisObject-Oriented?

•Objectorientationisanapproachto

softwaredevelopmentthatorganizesboth

theproblemanditssolutionasacollection

ofdiscreteobjects;

•Itisakindofrepresentationthatdescribe

object'sdatastructureandbehavior.

•Itisakindofmodelingtechnology.

Characteristicsof00Representation

•Identity-name,reference,handle

•Abstraction

•Classification

•Encapsulation

•Inheritance

•Polymorphism

•Persistence

The00DevelopmentProcess

•Beconsistencyofterminologyandof

-Theproblemandthesolutionweredescribedin

sameterms:classes,objectsmethods,attributes,and

behaviors.

•Beconsistencyofperspective

-Staticviews

-Dynamicviews

-Restrictions

TendencyforChangewhenUsing00Paradigm

(Jacobsonetal.1995)

Characteristicofsoftwareproduct/projectProbabilityforchange

ObjectsderivedfromtheapplicationLow

Long-livedinformationstructuresLow

Passiveobject5sattributeMedium

SequencesofbehaviorMedium

InterfacewiththeoutsideworldHigh

FunctionalityHigh

OORequirements

•OOrequirementsanalysisisusuallydoneintheuser's

language.

•OOrequirementsanalysisdiscussestheconceptsand

scenarioslikelyinapplicationdomain.

-Theconceptsincludeinformation,service,and

responsibilities.

-Domainknowledgeenablesbothdevelopersandusersto

understandtheproblems.

•Therequirementsdefinitioncanbeindependentof

implement.

00Design

•Requirementspecification,thefirststepsofdesign.

•Torepresentasystemdesign

-First,toidentifyandrepresentclassesandobjects.

-Second,toidentifytheinteractionsandrelationships

amongobjectsandclasses.

•Associations

•Compositions

•Aggregations

•Inheritance

•Toprovidethedetailsinprogramdesign.

-Insertcomputationalfeaturesinthemodels

-Insertsomeclasslibrarydetails

-Considernonfunctionalrequirements

UseCases(用例)

•Describeparticularfunctionalitytoexhibithow

auser,externalsystem,andotherentitydialog

withthesystem.

•Scenario场景

•Script脚本

Usecasediagrams(用例图)

•Actor(角色)

-Aentityinteractingwiththesystem

-Orarolethatanentityplayswithrespectofthesystem

,User

•Device

,Anothersystem

•Cases(用例)

-Adepictionofsomeaspectoffunctionality

•Extensions

-Toextendausecasetoillustrateadifferentordeeper

perspective.

•Uses

-Actuallyareuseofanalready-definedusecase

Overviewofroyalservicestation

Aactoro

Standfbracase

(Billing^)

Customer\

\

(^^efiielmg^)(^^arking^JMaintenance

Firstextensiontoincludepreventivemaintenance

Secondextensiontoincludecreditcardsystem

Thirdextensiontoincludeinventoryandaccounting

FuelOrderingPartsOrdering

systemsystem

UseUMLtoRepresent00

•OMG(ObjectManagementGroup)haveadopted

UMLasthe00notationalstandard.

•UMLcanbeusedtovisualize,specify,or

documentaproblem.

•UMLcanbeusedthroughoutthesoftware

developmentprocess.

UMLdiagrams

•Staticviewisdepictedwith

-Usecases(用例图)

-Classdiagrams(类图)

-Packagediagrams(包图)

-Deploymentdiagrams(酉己置图)

•Dynamicviewisdepictedwith

-Statediagrams(状态图)

-Activitydiagrams(活动图)

-Sequencediagrams(顺序图)

-Collaborationdiagrams(合作图)

•Restrictionsandformalization

-BeexpressedwithOCL(objectconstraintlanguage)

00SystemDesign

•Fivelevelsof00design

-Identifysubjects

-Identifyclassesandobjects

-Identifyattributes

-Identifystructures

-Identifyservices

Determinecandidateclasses

•Somequestionscanhelpustogroupthe

candidateclassesandobjects.

-Whatneedstobe"processed“insomeway?

-Whatitemshavemultipleattributes?

-Whendoyouhavemorethanoneobjectinaclass?

-Whatisbasedontherequirementthemselves,not

derivedfromyourunderstandingofthe

requirements?

-Whatattributesandoperationsarealwaysapplicable

toaclassorobject?

RelatedRequirementStatements

Acustomerhastheoptiontobebilledautomaticallyatthetimeof

purchase(offuel,maintenance,orparking)ortobesentamonthly

paperbill.Ineithercase,customerscanpayusingcash,creditcard,

orpersonalcheck.RoyalServiceStationfuelissoldaccordingto

pricepergallon,dependingonwhetherthefuelisdiesel,regular,or

premium.Serviceispricedaccordingtothecostofpartsandlabor.

Parkingissoldaccordingtodaily,weekly,andmonthlyrates.The

pricesfbrfuel,maintenanceservices,parts,andparkingmayvary;

onlyManny,thestationmanager,canenterorchangeprices.Athis

discretion,Mannymaydesignateadiscountonpurchasefbra

particularcustomer;thisdiscountmayvaryfromonecustomerto

another.A5%localsalestaxapplestoallpurchase.

TentativeclassesofRoyalServiceStation

•Personalcheck•Services

•Paperbill•Discounts

•Creditcard•Tax

•Customer•Parking

•Stationmanager•Maintenance

•Purchase•Cash

•Fuel•Prices

FirstGroupingofAttributesandClasses:Stepl

ClassesAttributes

CustomerPersonalcheck

MaintenanceTax

ServicesPrice

ParkingCash

FuelCreditcard

PaperbillDiscounts

Purchase

Stationmanager

RelatedRequirementStatements

Thesystemappliesonlytoregularrepeat

customers.Aregularrepeatcustomermeansa

customersidentifiedbyname,addressandbirth­

datewhousesthestation'sserviceatleastonce

permonthfbratleastsixmonths.

Thesystemwillsendperiodicmessagesto

customers,remindingthemwhentheirvehicles

areduefbrmaintenance.Normally,maintenance

isneededeverysixmouths.

FirstGroupingofAttributesandClasses:Step2

ClassesAttributes

CustomerPersonalcheck

MaintenanceTax

ServicesPrice

ParkingCash

FuelCreditcard

PaperbillDiscounts

PurchaseBirthdate

PeriodicmessageName

StationmanagerAddress

Forthefullsetofrequirements,we

mightexpandourtabletoinclude

alloftheclasses.

FirstGroupingofAttributesandClasses:Step3

ClassesAttributes

Customer

MaintenancePersonalcheck

ServicesTax

Parking

FuelPrice

Paperbill

PurchaseCash

Periodicmessage

StationmanagerCreditcard

Warningletter

PartsDiscounts

Accounts

InventoryBirthdate

CreditcardsystemName

Part-orderingsystem

Fuel-orderingsystemAddress

IdentifyBehavior

•Lookfbrparticularitemsthatsuggestbehaviors:

(Extractverbsfromtherequirementsstatement)

-Imperativeverbs

-Passiveverbs

-Actions

-Thingsorremindedevents

-Roles

-Operatingprocedures

-Serviceprovidedbyanorganization

•Thebehaviorswillbecomeactionsor

responsibilities.

UseUMLtodescribetherelationship

amongtheobject,classes,andbehaviors

bill

Issuedate:Date

Paymentdate:Date

Price()

Taxes()

Customers()

Purchase()

Add_to_bill(customer,amount,date)

Inheritance

Fourkindsofrelationship

•Generalization

•Aggregation

•Association

•composition

UMLnotations

association

composition

aggregation

dependency

navigation

Associationofclasses

Qualifiedassociation

Qualifiedassociation

SwayBackandForth

•AbstractaMessageClassfromwarningletterand

periodicmessage.

•Thefuelclassshouldbeconnectedtoinventoryclass

•Deletetheaccountclass(hasonlyoneattribute)andadd

theaccountnumbertothecustomerclass.

•Addthreenewclass,refuel,parkingspace,service.

-Fortakingadvantageofthepolymorphism

•Thepriceanddiscountcanbedifferentdependingonwhatserviceis

required.

-Removethediscountratefromthefuelclassandputitinthe

partclass.

-Removethepricefromthefuelclassandaddittotherefuel

class.

-Putthepriceofaparkingspace,locationintheparkingclass.

CustomerPeriodic

Messages

nameWarningletter

Address

Birthdatetexttext

Purchase

dateBillStation

CreditCardManager

systemtaxrateissuedate

Paymentdate

Services

ParkingSpacepriceVehicleMaintenance

locationdiscountrateissuedate

Paymentdate

Refuel

Part

gallons£7Inventory◊

ocationricepartnumber

price

Price

ParksFueldiscountrate

FuelOrderingOrdering

min_quantity=l00systemsystem

Currentquantity

SwayBackandForth

•DeleteStationManagerclass

•Addservicestationtohandlethetrackingof

dormantaccounts

OtherUMLDiagrams

•Classdescriptiontemplate

•Packagediagrams

•Sequencediagrams

•Collaborationdiagrams

•Statediagrams

•Activitydiagrams

Classdescriptiontemplate

•Templatetellus

-thepositionoftheclassintheoverallhierarchy

-exportcontrols

-cardinality

-associations

•Templatealsospecifies

-theoperationsintheclass

-thepublicinterfacetotheclass

Templatefbrtherefuelclass

Classname:refuelPublicinterface:

Category:serviceOperation:

Externaldocuments:price

Exportcontrol:PublicPrivateinterface:

Cardinality:nAttributes:

Hierarchy:Gallons

Super-classes:servicesprice

Associations:Implementation:

Operationname:priceAttributes:

Publicmemberof:refuelGallons

Documentation:price

Preconditions:Statemachine:no

Gallons>0

Objectdiagram:unspecifiedConcurrency:sequential

Semantics:Persistence:transient

final_price=gallons*price

Concurrency:sequential

Packagediagrams

Standfor

dependent

Interactiondiagrams

•Todescribehowoperationsandbehaviors

arehandledbyobjects.

•Todescribehowtheobjectsareconnected

statically.

•Basedoneachusecase

•Twokindsofinteractiondiagrams

-Sequencediagrams

-Collaborationdiagrams

Sequencediagramfbrtherefuelusecase

CustomerServiceStationCreditCardPurchaseRefuel

System

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论