Tải bản đầy đủ - 0 (trang)
Chapter 2. Creating a New System

Chapter 2. Creating a New System

Tải bản đầy đủ - 0trang

Chapter2.CreatingaNewSystem

INTHISCHAPTER

SystemRequirements

SystemDesignIssues

TheDevelopmentProcess

DataProcessingMethods

Thischaptertakesthereaderstep-by-stepfromthedesignstageofa

newprojectthroughtothestartoftheimplementationstage,notingat

everystepwhereoptimizationopportunitiescanbefound.Assuchitis

alsoahelpfulchecklistforconsultationwheneverthelearnedtechniques

areputintopractice.



SystemRequirements

Performanceandfootprintissuesobviouslyplayalargeroleinboththe

implementationphaseandthedesignphaseofasoftwareproject.

However,thisisnotwherethewholeprocessstarts.Therequirements

phaseisthefirstfactor.Thefollowingsectionsdiscusswhyandhowthe

requirementsimpactperformanceandfootprint.



SettingPerformanceTargets

Therequirementsspecificationshoulddescribeinclearandmeasurable

termswhatisexpectedfromthefinalproduct.Itisinessencethe

blueprintofwhatthedesignandimplementationresultsneedtoachieve.

Soinadditiontocontainingallthatneedstobetestedinthefinalproduct,

agoodandrepresentativerequirementspecificationcanalsobeusedas

abasisformakinginitialcostcalculations.Consequently,the

requirementsarewheretofactorinexpectationsconcerningthespeedof



aprogramandthehardwarenecessaryforexecution.

Therequirementsaredeterminedwithhelpfromtheclient—oftenthrough

aseriesofinteractivesessions.Whenareplacementsystemistobe

built,itisnecessarytogetafeelfortheexistingsystembeingusedand

theproblemsitsuffersfrom.Youshouldexaminetheoldsystemandhow

andwhenitinteractswiththoseusingit.Thishelpsinascertainingwhich

partsofthesystemreallyneedtobeleanandfastandwhichpartsare

lesstime-critical.

Forexample,consideracompanywhoseservicescauseittohavea

largeclientdatabase.Itcouldbeimportantforsuchacompanytohavea

databasesetupthatallowsfaststorageandretrievalofclientinformation

becauseitneedstobeusedduringphoneconversationswithclients.

Becauseallthedataprocessingisdoneafterhours,it'sfarlessimportant

howquicklythissystemprocessesdata.

However,it'snotenoughtomerelyexaminetheoldsystemandidentify

itsproblemareas.Therequirementsfortheoldsystemareboundtobe

verydifferentfromthosetobesatisfiedbythenewone.Peoplehave

higherexpectationsofanewsystemwhenanoldsystemisautomated

(oranautomatedsystemisupdatedorreplaced)becausemoretimeand

moneyisinvested.Inpractice,ithappensalltoooftenthatthelackof

hardperformancerequirementscausesashiftindesignfocus.So

specifictargetsneedtobeset.Withonlyfunctionalrequirementstoguide

them,designerstendtofocusonelegantsolutionsforitems,suchas

frameworksetuporreusabilityofcomponents.Butallthatamountsto

nothingifthefinalproductisjusttooslow.Andthesameholdstrue

wherefootprintsareconcerned.Aprogrammightbeflexibleand

expandable,butifitdoesnotfitonthetargethardwareinthefirstplace,

nobodywilleverconsiderexpandingit.Soit'simportanttogetafeelfor

howmuchspaceisactuallynecessary.It'sevenbettertoknowhow

muchspacewillbeneededinfuture.Ifyoucan,youshouldtelltheclient

exactlyhowmuchextraharddrivespaceheneedsforevery1,000new

users.

Thefollowingsectionsfocusonunexpectedrequirementsareasthat

impactperformanceandfootprintexpectations.



StabilityandAvailability

Stabilityandavailabilityareveryimportantrequirementsnotonlyfor

software,butalsoforentiresystems(softwareplushardware)because

theyimpactthereliabilityofthesystem.

Asystemisunreliablewhenitcrasheseveryfewhours,produces

unpredictableresults(inaccuracyorevenresponsespeed),orwhenits

levelofreliabilitydependsontheamountoftimeithasbeenactive

(uptime).Aclientexpectsthesystemtobereliablearoundtheclock.Itis

certainlyundesirableforthedesignteamtohavetomakeclearthat

certainsituationscancauseactualdatalossbecauseofahardwareor

softwareproblem.Thismeanstherequirementsmustspecifythegoal

levelofstabilityandavailability.Thereasonhereistwofold:first,tomake

sureproperassessmentsandadjustmentscanbemadeduringdesign

andimplementationtoinsureasufficientlyhighreliabilitylevel;second,to

maketheclientawareofthenecessarytradeoffs.Stabilityandavailability

comeatacertaincost.Theyinfluenceperformanceandfootprintsize,

developmenttime,hardwarecosts,andsoon.Thiscostcurveisnot

lineareither.Itmayberelativelyeasytobuildasystemwithan80%level

ofreliability.Costsarehigherforthenext15%,butthefollowing4%

mightcostasmuchasthewholesystemtogether,andthefinal1%may

beunmentionablyhigh.Theclientneedstodecidehowmuchthelastfew

percentagesareactuallyworthinvestingin.

Thefollowingsectionsexaminetheimpactofstabilityandavailability

requirementsonperformanceandfootprint.

ImpactofStabilityandAvailabilityonPerformance

Characteristicsofthedatastreamasystemshouldbeabletohandle

continuouslyareanimportantpartofitsrequirements.Althoughasystem

canbeequippedwithbufferstocaptureandstorecertainburstsof

information,theimplicationisthattheremustbe,atsomepointbefore

thebuffersoverflow,someextratimetocatchupandclearthebuffers.

Fewapplicationareasaregeneroustowardanydataloss,soit's

importanttoknowwhatkindofdatarateaprogramcanhandle

continuously.Thespecifictaskthesystemisdesignedtocarryout



determineshowthisdatarateisactuallyspecified(therateofinputdata

tohandle,thenumberofdatabaseaddressestostoreorprocessper

minute,andsoon).Consultationswiththeclientshoulddeterminethis

datarate.Alphaandbetaversionsofthesystemshouldbeputthrough

stresstests.Duringthesetests,youfindouthowtaxingitisforthe

systemtocomplywiththerequirements.Thesystemisclearlyonthe

vergeofmaxingoutifasimpleextratask,suchasmovingthemouse

pointerormanipulatingpartsoftheuserinterface,causesdifficulties.The

continuousdatastreamitcanhandleisthuslowerthantheoneitisbeing

fed.

Enablingtheuseofbufferstoprotectagainstsuddenorunexpected

burstsofdatacanbespecifiedwithintherequirementsdocument,butas

amaximumor"burst"datarate.Itisimportanttonotealsothelengthof

timethesystemisabletokeepupwiththismaximumrate(beforeits

performancedeclinesorbecomesunreliable)andhowmuchtimethe

systemneeds(atthenormaldatarate)torecoverandbereadyfora

followingburst.

Acloselyrelatedissueistheresponsivenessofasystem.Whathappens

wheninputsuddenlystartspouringinafteralongperiodofdrought?

Doesthesystemrespondinduetimeordoesitexperiencedifficulties?It

seemsmorethanlogicalthatthisshouldnormallynotbeaproblem,but

evenahouseholdPCineverydayusecanexperiencethis.Background

processes(suchasscreensavers,registryupdates,viruscheckers)

ensurethatthePCdoesnotrespondinstantaneouslyafteraperiodof

lowinteraction.Thehardwarealsoplaysanimportantrolein

responsiveness,suchasgreenPCoptions,powersavers,thesuspend

mode,andsoon.Whenasystemhastoguaranteeacertainresponse

time,theseoptionsmostlikelyneedtobekeptincheckormaybeeven

turnedoff.Itmightalsobepossibletosetspecificpartsofthesystemin

somekindofstandbymodeandkeeptheinputchannelmonitoring

active.Thishighlightsthenextareaofconsideration;thecommunication

channels.Ifasystemcommunicateswithitsenvironmentviaamodem

connection,forexample,itmightbenecessarytokeepacontinuous

connectionratherthantoallowthemodemtologoff,afterwhichacostly

reconnectwouldbeneededbeforemoredatacanbedown-oruploaded.

Theanalysisanddesignphasesofaprojectshoulddeterminehowbest

toproceed—thatis,whichoperatingmodetoallowforeachpartofthe



system.

ImpactofStabilityandAvailabilityonFootprint

Thedataburstexamplegivenearlierdemonstratesclearlythetradeoff

betweenstabilityandavailabilityononehandandthefootprintonthe

other.Thelongerthesystemshouldbeabletohandlehigherdatarates,

thelargeritsbuffersneedtobe.

Anotherareatoconsideristhespaceneededforstoreddata.To

guaranteeahighlevelofreliability,itmaybeprudenttoduplicatekey

setsofdata.Think,forexample,oftheDOS/WindowsOSwheretheFAT

(containinginformationonwhereandhowfilesarestored)iskeptin

duplicate.Also,thestoragemediumitselfcandictateanecessary

cautiousapproach.Youmighthavetotakeintoaccountthenumberof

timesamediumcanbewrittentoandtheaveragenumberofcorrupted

memoryunitsthatoccurduringusage.Forinstance,corruptedsectorson

harddisksmustbeconsideredbeforehand.Extraspacemaybeneeded

toallowextensiveerrorcorrection(Hammingcodes)andsoon.

Formoredetailsonoptimizinginputandoutputofdata,seeChapter12,

"OptimizingIO."



Concurrency

Whenyousetuptherequirementsforasoftwareprojectorasystem,it's

importanttotakeintoaccounttheenvironmentinwhichitneedsto

function.Partoftherequirementsincludeassessmentsofusageof

resourcesnotonlybythesystem,butalsobytoolsandtaskslikelytobe

usedsimultaneously.It'swisetodetermineanswerstothesequestions:

Aretheremoreapplicationsrunningonthesystemsimultaneously?

Ifso,identifythemandfindoutabouttheirresourceusage.Forexample,

acalculatorprogramusinglargepartsofsystemresourcesisnotgoingto

beveryfunctionalasitismostlikelytobeusedasasecondorthird

applicationtoaidinsubsetsofalargertask.Also,certainresourceshave



tobeclaimedandshared:serialandparallelports,interrupts,DMA

channels,inputdevices(suchasakeyboardormouse)andsoon.

Willanumberofusersbeworkingwiththesystemsimultaneously?

Ascenariolikethisisofcoursepossiblewithamulti-userOS,likeUNIX,

buthasanimpactontheresourcesavailableforeachuser.Itmighteven

influenceimplementationdecisionsasusedstrategies(client/server

strategies,COM,CORBA),lockingmechanisms,andprivatecopiesof

dataforprocessing.

Investigatingtheresultingavailabilityofstorageandcomputingpowerwill

resultinarequirementoftheconstrainedcontextinwhichtheprogram

shouldbeabletorun.



ChoosingtheTargetSystem

Basedontheinformationfromtheprevioussections,itshouldbe

apparentwhatisexpectedfromtheprogramorsystem.Itshouldalsobe

clearthatdecisionshavetobemadewhichwillaffecttheoverallcostof

theproject.Higherreliabilitymeansmoreexpensivehardwareandlonger

developmentandimplementationtimes.Often,youevenhavetochoose

betweenusinghardwareandusingsoftwaretosolveaproblem.The

obviousprosherearethespeedofhardwaresolutionsandtheflexibility

ofsoftwaresolutions;theobviousconsaretheextracostandinflexibility

ofhardwaredevelopment.Buttherearemore-involvedconsiderations;

whenthesoftwareisabletodoalotoferrorrecovery,forexample,the

hardwarecanbelessfault-tolerant.Thecostofbeingfaulttolerantwill

sometimesbehigherinsoftware,othertimesinhardware,so

comparisonsreallyneedtobemadeonacase-by-casebasis.Thereare

naturallimitstotheavailablechoices,ofcourse.Forexample,software

willneverbetolerantenoughtocompensateforabrokenpowersupply.

Afteryoudeterminewhich(ifany)partsoftheprojecthavetobedonein

with(dedicated)hardware,takeacloserlookatthesoftwaretouse:

WhatkindofOSisneeded?Thelevelofreliabilitydecidedonmayvery

wellinfluencethechoiceofOS.WillacheaperorstandardOSsuffice,or

isaproven,industrialOSwarranted?Beforethisquestioncanbe



answered,it'snecessarytolookatperformance,footprint,andprice

tradeoffs:

WhatkindofimpactdoestheOShaveonavailableCPUcycles?

(Considerthisfordifferentactivities,suchasmemoryallocation,file

storage,andsoon.)

WhatisthefootprintoftheOS?(Sometimesdifferentversionsofan

OScanbechosen,eachwithitsownsubsetoffunctionalityand

footprintsize.)

HowmuchoverheaddoestheOScreate?(Howmuchmemoryor

performanceislostwhenspawningatask,openingafile,creatinga

fileondisk,andsoon.)

Whatistheminimalguaranteedresponsetime?(Andtowhatextent

isthisinfluencedbybackgroundtaskslikeupdatingregistry

information,doingpageswapping,andsoon.)

Isitareal-timeOS?(Andisonereallyneeded?Seerequirements.)

Thehardwareandsoftwarechoicesaffectperformanceandfootprint.

Thisissomethingwhichwillbereflectedagaininthedesign.The

followingsectionsaddressthis.



SystemDesignIssues

Aftertherequirementsforaprogramorsystemaresuccessfully

identified,itistimetogetbusywiththedesign—thatis,thecomplete

packageofdocumentationthatanimplementerneedstocreatethefinal

product.Insometechnicalliterature,aseparateanalysisphaseis

identified.However,thisbookpresentsanalyzingtheprogramandits

surroundingsasfullyintegratedwithfindingtherequirementsandmaking

thedesign.Assuch,itwouldbeunnaturaltotrytotreatanalysis

separately.

Thenextsectionexaminesperformanceandfootprintissuestobedealt

withduringthedesignphase.Thefirstpartdiscussesthestatic

frameworkofaprogram,andthesecondpartdiscussesthedynamic



objectsofaprogram.



ApplicationFramework(Static)

Theprevioussectionhighlightedkeyareaswhereperformanceand

footprintrequirementscouldbefound.Ofcourse,thesealsohave

implicationswherethedesignisconcerned.Thissectionhighlightsthe

keyareasforthedesignoftheprogramitself:

DesignFocus

Isitbettertooptimizeaprogramforperformanceorforfootprint?

Designinga(fast)programwherememoryisnotascarceresource

completelydiffersfromtryingtosqueezefunctionalityintoasmall

runtimespace(suchas,in-placealgorithmsversusmemory-hungry

input-to-outputconversionalgorithms).Consideroptimizingjust

certainpartsofaprogramforfootprintsizetosavesomememory.

Usingthatsavedmemoryinotherpartsoftheprogramallowsthese

tobeevenbetteroptimizedforperformance.

FunctionalModeling

Isitbesttobuildonelargeprogramcontainingallfunctionalityorto

splittheprogramintosmallertools?Byrunningthetoolsseparately

(maybeevenfromasinglecontinuousmenu),itispossibletosave

considerablyonruntimememory.

LookandFeel

Howistheprogramoperated?Wherearedelaysexpected?What

kindoffeedbackdoestheuserexpect?Whenandwheredoyouuse

doublefunctionality(mouse,andhotkeys,andsoon)?Consider

havingslowoperationstakeplaceinthebackgroundwhilethemain

application(separatethread)staysresponsivetotheuser.

Subsystems

Whatkindofsubsystemscanyouidentify?Howdothey

communicate?Dotheycalleachother'sfunctions?Dotheytransfer



dataorsharethesamedata?

Flexibility

Howflexibledoyouwanttobe(andneedtobe)forfuturechanges?

Doyoubuildawildlygenericframeworkorconcentrateonlyonthe

functionalityrequiredbythecurrentcustomer?Areyouactually

preparedtosacrificeperformancetobemoreflexible?

DataFlow

Howdoesthedataflowthroughthedesignedcomponents?Are

theretimedependencies?Haveyouconsideredwherescheduled

andwhereevent-drivenmechanismsareappropriate?

Portability

Doyouwanttobeflexibleenoughtoallowthesoftwaretobeeasily

rebuilttorunonotherhardwaresystems(portingthesoftware)?If

so,thesetupofthesoftwarecannotbemadehardwaredependent.

Allhardwareinteractionswillneedtobedonethroughageneric

mechanism.Anyhardware-specificelementswillneedtobeputin

separatemoduleswhichwillbereplacedduringaport.

Reusability

Doyouexpecttouse(parts)ofyourprograminsomefuture

contexts?Anypartstobereusedshouldthenbeidentifiedandput

togetherinfunctionalgroups.Thisistruealsofortherelevant

documentation.

IntelligencePlacement

Doyouwantintelligentsubmodulesordoyouwanttokeepallthe

decision-makingpowerinthemainmodule?Thedifferencesarethat

eitherthesubmodulesbecomequitelargeorthemainmoduledoes,

andportabilityandreusabilityarethereforeinfluenced.

Thesameintelligencechoicesneedtobemadeconcerning

client/serverapplications.Whodoesmostofthework,theclientor



theserver?



ObjectLifetime(Dynamic)

Generally,programsaremadeupofseveralfunctionalobjectsofwhicha

numberofinstancescanbefoundinmemoryduringruntime(classes,

threads,libraries,andsoon).Objectswhicharenotpartofthestatic

frameworkofaprogramaregenerallycreatedanddestroyedasneeded.

Thissectionexaminestypicallifecyclesofsoftwareobjects.

IntermediateObjects

Intermediateobjectsareusedtostoreintermediateresultsand

informationduringprocessing.Theyaretypicallyusedwithinacertain

partofaprogramonly,oftenlocalizedinsideasinglefunction,andhave

averyshortlifespan.Theydonotoutlivetheprogram,andtheydonot

outlivethefunctionormoduletheyareusedin.Anexampleof

intermediateobjectsisthevariablesdeclaredinsideaclassorfunction,

asshowninListing2.1:

Listing2.1IntermediateObjects



~

classPaintCanvas;

~

PaintCanvasManager::DoWop()

{

inta;//intermediate

~

PaintCanvasfirstCanvas;//interme

~

intintMed=nrOfProcessedCanvasses;//inte

if(~~

{



nrOfProcessedCanvasses=IntMed;

}

~

}

PersistentObjects

Becausepersistentobjectsstayaliveaftertheprogramterminates,they

arestillwhentheprogramrestarts.Theseobjectsareusedtoretain

informationaboutapreviousrun.Examplesofthisarefilesinwhich

programdataisstoredandkeyswhicharesetintheregistryoftheOS

(Windowsusesthis).Suchobjectswillevenoutliveacomputerreboot.

Otherpersistentobjectsmayberesidentinmemory,liketheclipboardto

whichyoucancopypiecesoftextorpicturesfromforinstance,aword

processor.Dedicatedhardwaremayevenhavespecialmemoryreserved

forstoringpersistentobjects,disks,EEPROM,FLASH,andsoon.The

advantageofkeepingobjectssuchastheseinmemoryisthespeedwith

whichtheycanberecalledwhentheyareneededagain.Thiscaneven

increaserestarttimeoftheprogramorthededicatedhardwareonwhich

thesystemruns.

Decisionstomakeinmemorymanagement(aspartoftheprogramor

system)canincludedeletingcertainobjectsormovingthemtodiskto

(temporarily)freesomeruntimememory.

TemporaryObjects

Temporaryobjectsfallsomewherebetweenintermediateandpersistent

objects.Theirlifetimeisgenerallylongerthanthatofintermediate

objects,meaningtheyoutlivefunctionsandprogrammodules;however,

theydonotoftenoutlivetheprogramitself.Anexampleofatemporary

objectistheUndoBuffer.Foundinmostwordprocessors,theUndo

functioncanrecallapreviousversionoftext.Thebuffercontentchanges

constantlyduringprogramexecution,butthebufferitselfisaccessibleas

longastheprogramisactive.



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Chapter 2. Creating a New System

Tải bản đầy đủ ngay(0 tr)

×