Tải bản đầy đủ (.pdf) (533 trang)

Addison wesley applied c plus plus practical techniques for building better software may 2003 ISBN 0321108949

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (3.2 MB, 533 trang )




TableofContents
Examples

AppliedC++:PracticalTechniquesforBuilding
BetterSoftware
ByPhilipRomanik,AmyMuntz
Publisher :AddisonWesley
PubDate :April21,2003
ISBN :0-321-10894-9
Pages :352

"Ireallylikethesoftwareengineeringadvicegiven
here.Asthechiefengineer/architectforalarge
developmentgroup,Icansaywithcertaintythatthe
advicegiveninthisbookabouthowreal-world
projectsmustworkisrightonthemark."
-SteveVinoski,coauthorofAdvancedCORBA
ProgrammingwithC++,columnistforC/C++Users
JournalandIEEEInternetComputing,andChief
Architect,IONATechnologies


AppliedC++isapractical,straightforwardguideto
developinghigh-quality,maintainablesoftware.It
reflectsthepowerofC++,templates,andthe
StandardTemplateLibraryforindustrial-strength
programming.Whetheryouareasingledeveloper
orworkinalargeteam,thetipsandtechniques


presentedinthisbookwillhelpyouimproveyour
languageanddesignskillsandshowyouhowto
solvesubstantialproblemsmoreeffectively.
Theauthors,drawingontheirextensiveprofessional
experience,teachlargelybyexample.Toillustrate
softwaretechniquesusefulforanyapplication,they
developatoolkittosolvethecomplexproblemof
digitalimagemanipulation.Byusingaconcrete,
real-worldproblemanddescribingexactfeature,
performance,andextensibilityrequirements,the
authorsshowyouhowtoleverageexistingsoftware
componentsandthetoolsinherentinC++tospeed
development,promotereuse,anddeliversuccessful
softwareproducts.
InsideAppliedC++,youwillfind:
AC++templatesprimer
Workablecodingguidelinesandextensive


codingexamples
Quicklistsofneed-to-knowinformationabout
Exceptions,Assertions,andStandardTemplate
Librarycomponents
Atechniqueforeffectivelyusingprototypesto
moveyourdesignfromaninitialconcepttoa
robustsolution
Atechniqueforbuildingdebuggingsupportinto
yoursoftwarewithoutatonofoverhead
Thirteenspecifictechniquestoimprovethe
overallperformanceofyoursoftware








TableofContents
Examples

AppliedC++:PracticalTechniquesforBuildingBetterSoftware
By

PhilipRomanik,AmyMuntz

Publisher :AddisonWesley
PubDate :April21,2003
ISBN :0-321-10894-9
Pages :352

Copyright
TheC++In-DepthSeries
TitlesintheSeries
Preface
IntendedAudience
HowtoUseThisBook
ConventionsWeUse
Acknowledgments
Chapter1.
Introduction

Section1.1.
ImagingBasics


Section1.2.
Summary
Chapter2.
ATestApplication
Section2.1.
ImageClassDesign
Section2.2.
ThumbnailClass
Section2.3.
Implementation
Section2.4.
Summary
Chapter3.
DesignTechniques
Section3.1.
MemoryAllocation
Section3.2.
Prototyping
Section3.3.
Summary
Chapter4.
DesignConsiderations
Section4.1.
CodingGuidelines
Section4.2.
ReusableCode

Section4.3.
DesigninginDebuggingSupport


Section4.4.
Summary
Chapter5.
SystemConsiderations
Section5.1.
MultithreadedandMultiprocessDesigns
Section5.2.
ExceptionHandling
Section5.3.
Compile-TimeVersusRun-TimeIssues
Section5.4.
CodingforInternationalization
Section5.5.
Summary
Chapter6.
ImplementationConsiderations
Section6.1.
FinalizingtheImageComponents
Section6.2.
FinalizingtheImageClass
Section6.3.
AddingGlobalImageFunctions
Section6.4.
FinalizingInterfacestoThird-PartySoftware
Section6.5.
Summary

Chapter7.


TestingandPerformance

Section7.1.
UnitTests
Section7.2.
PerformanceTuning
Section7.3.
Summary
Chapter8.
AdvancedTopics
Section8.1.
MemoryIssues
Section8.2.
LanguageConstructIssues
Section8.3.
ExtendingtheFramework
Section8.4.
Summary
AppendixA.
UsefulOnlineResources
SectionA.1.
Software
SectionA.2.
Standards
AppendixB.
CD-ROMInformation
SectionB.1.

Contents


SectionB.2.
Framework
SectionB.3.
Prototypes
SectionB.4.
Utilities
SectionB.5.
Delegates
Bibliography


Copyright
Manyofthedesignationsusedbymanufacturersandsellersto
distinguishtheirproductsareclaimedastrademarks.Wherethose
designationsappearinthisbook,andAddison-Wesleywasawareofa
trademarkclaim,thedesignationshavebeenprintedwithinitialcapital
lettersorinallcapitals.
IntelIntegratedPerformancePrimitivesandIntelC++Compilerare
trademarksorregisteredtrademarksofIntelCorporationorits
subsidiariesintheUnitedStatesandothercountries.
Theauthorsandpublisherhavetakencareinthepreparationofthis
book,butmakenoexpressedorimpliedwarrantyofanykindand
assumenoresponsibilityforerrorsoromissions.Noliabilityisassumed
forincidentalorconsequentialdamagesinconnectionwithorarisingout
oftheuseoftheinformationorprogramscontainedherein.
Thepublisheroffersdiscountsonthisbookwhenorderedinquantityfor
specialsales.Formoreinformation,pleasecontact:

U.S.CorporateandGovernmentSales
(800)382-3419

ForsalesoutsideoftheU.S.,pleasecontact:
InternationalSales
(317)581-3793

VisitAddison-WesleyontheWeb:www.aw.professional.com
LibraryofCongressCataloging-in-PublicationData


Romanik,Philip.
AppliedC++:practicaltechniquesforbuildingbettersoftware/Philip
Romanik,
AmyMuntz.
p.cm.
Includesbiographicalreferencesandindex.
ISBN0-321-10894-9(alk.paper)
1.C++(Computerprogramlanguage)2.Computer
softwareDevelopment.I.Muntz,Amy.II.Title.
QA76.73.C153R662003
005.13'321
2003040449
Copyright©2003byPearsonEducation,Inc.
Allrightsreserved.Nopartofthispublicationmaybereproduced,stored
inaretrievalsystem,ortransmitted,inanyform,orbyanymeans,
electronic,mechanical,photocopying,recording,orotherwise,withoutthe
priorconsentofthepublisher.PrintedintheUnitedStatesofAmerica.
PublishedsimultaneouslyinCanada.
Forinformationonobtainingpermissionforuseofmaterialfromthis

work,pleasesubmitawrittenrequestto:

PearsonEducation,Inc.
RightsandContractsDepartment
75ArlingtonStreet,Suite300
Boston,MA02116
(617)848-7047
Textprintedonrecycledpaper


12345678910CRS0706050403
Firstprinting,April2003

Dedication
ForKaren,mytrueloveandbestfriend.
PR
ForGary,whomakesallmydreamspossible;andforEthan,whose
smileandlaughterbrighteneachday.
AM


TheC++In-DepthSeries
BjarneStroustrup,Editor
"Ihavemadethisletterlongerthanusual,becauseIlackthetime
tomakeitshort."
BLAISEPASCAL
TheadventoftheISO/ANSIC++standardmarkedthebeginningofa
neweraforC++programmers.Thestandardoffersmanynewfacilities
andopportunities,buthowcanareal-worldprogrammerfindthetimeto
discoverthekeynuggetsofwisdomwithinthismassofinformation?The

C++In-DepthSeriesminimizeslearningtimeandconfusionbygiving
programmersconcise,focusedguidestospecifictopics.
Eachbookinthisseriespresentsasingletopic,atatechnicallevel
appropriatetothattopic.TheSeries'practicalapproachisdesignedtolift
professionalstotheirnextlevelofprogrammingskills.Writtenbyexperts
inthefield,theseshort,in-depthmonographscanbereadand
referencedwithoutthedistractionofunrelatedmaterial.Thebooksare
cross-referencedwithintheSeries,andalsoreferenceTheC++
ProgrammingLanguagebyBjarneStroustrup.
AsyoudevelopyourskillsinC++,itbecomesincreasinglyimportantto
separateessentialinformationfromhypeandglitz,andtofindtheindepthcontentyouneedinordertogrow.TheC++In-DepthSeries
providesthetools,concepts,techniques,andnewapproachestoC++
thatwillgiveyouacriticaledge.


TitlesintheSeries
AcceleratedC++:PracticalProgrammingbyExample,AndrewKoenig
andBarbaraE.Moo
AppliedC++:PracticalTechniquesforBuildingBetterSoftware,Philip
RomanikandAmyMuntzTheBoostGraphLibrary:UserGuideand
ReferenceManual,JeremyG.Siek,Lie-QuanLee,andAndrew
LumsdaineC++In-DepthBoxSet,BjarneStroustrup,Andrei
Alexandrescu,AndrewKoenig,BarbaraE.Moo,StanleyB.Lippman,and
HerbSutterC++NetworkProgramming,Volume1:MasteringComplexity
UsingACEandPatterns,DouglasC.SchmidtandStephenD.Huston
C++NetworkProgramming,Volume2:SystematicReusewithACEand
Frameworks,DouglasC.SchmidtandStephenD.HustonEssentialC++,
StanleyB.Lippman
ExceptionalC++:47EngineeringPuzzles,ProgrammingProblems,and
Solutions,HerbSutterModernC++Design:GenericProgrammingand

DesignPatternsApplied,AndreiAlexandrescu
MoreExceptionalC++:40NewEngineeringPuzzles,Programming
Problems,andSolutions,HerbSutterFormoreinformation,checkout
theseriesWebsiteat />

Preface
ThisbookisaboutapplyingC++tosolvetheproblemsinherentin
buildingcommercialsoftware.Thoseofyouwhohaveworkedon
engineeringteamsbuildingcomplexsoftwarewillknowexactlywhatwe
meanbycallingitcommercialsoftware.
Commercialsoftwareisdeliveredtocustomers(internalorexternal)who
willrelyontheinterfaceyouprovide.Itmaybeinanembeddedsystem,
oritmaybeasoftwarelibraryorapplicationforstandardplatforms.No
matterwhereitultimatelyruns,thesoftwaremustbereleasedata
particulartimewithallofthefeaturesitneedstobesuccessfulinthe
market.Itissoftwarethatisbuiltbyonegroupofengineersand
potentiallyextendedandmaintainedbyotherengineers.Theengineers
whotakeovermaintainingthesoftwaremaynothavebeenpartofthe
originalteam,andtheymighthavetoaddfeaturesortrytofixproblems
whilevisitingcustomersites.
Gettingagroupofengineerstobuildacomplexpieceofsoftwareand
deliveritontimewithfullfunctionalityisoneofsoftwareengineering's
biggestchallenges.Anevenbiggerchallengeisbuildingthatsame
softwareinsuchawaythatitcanbehandedofftootherstoextendand
maintain.TheC++techniquesandpracticaltipswehavecompiledinto
thisbookhavebeenusedrepeatedlytoaccomplishjustthis.Inmany
cases,wedrawadistinctionbetweentheidealsolutionandthepractical
one.Wetrytoprovidediscussionsofthetrade-offssothatyoucanmake
informeddecisions,andwetellyouwhatourcriteriaarewhenselecting
onemethodoveranother.Weleaveittoyoutodeterminewhatworks

bestinyourapplication.Ourgoalistosharepracticaltechniquesthatwe
havefoundmadeourcommercialsoftwareeffortsmuchmoresuccessful
thantheyotherwisewouldhavebeen.Wehopeyouwillfindthemuseful.
Forthoseofyouwhoprefertolearnbylookingatthecode,youwillfind
plentyofexamples.Weillustrateallofthetechniquesbyusingaconcrete
examplethatrunsthroughoutthebook.Becauseitwasourexperiences
withimagingsoftwarethatpromptedustowritethisbook,ourexample


comesfromtheimageprocessingdomain,buttheC++techniquesare
applicabletoanydomain.
Westartwithasimple,althoughinadequate,applicationthatgenerates
thumbnailimages.Weusethisapplicationinourprototypingphasesto
experimentwithdifferentC++designandimplementationtechniques.
Theapplicationissimpletounderstandandtheresultsofapplying
variousC++techniquesareimmediatelyobvious,makingitanice
candidateforprototyping.
Thissimplethumbnailimagegeneratorhasmanyofthesameinherent
problemsthatourfinalimageframeworkwillhavetoaddress.The
applicationis:
Memoryintensive.Workingwithimagesrequiresefficientuseof
memory,becauseimagescangetquitelargeandunwieldy.
Managingmemorybecomescriticaltotheoverallperformanceofthe
application.
Performanceintensive.Whilegeneratingthumbnailsisa
straightforwardimageprocessingtechnique,othersthatwe
introducelaterinthebook(suchasedgesharpeningandnoise
reduction)requirethoughtfuldesignstomakethemusable.It'sgreat
tohavecoolimagefunctionstomanipulateyourdigitalimages,but
theyareuselessiftheytakeareallylongtimetorun.

Uponcompletion,youwillhaveanimageprocessingframeworkfor
manipulatingyourdigitalimagesandapracticaltoolkitofC++utilities.
Theframeworkwillprovideefficientimagestorageandmemoryusage,
routinesformanipulatingyourdigitalimages(likeedgesharpening,
imageresizing,noisereduction,edgedetection,imagesubtraction,and
more),interfacestothird-partysoftware,andmanyperformance
optimizations.Itwillbeausefulpieceofsoftwarethathaspractical
designandimplementationfeatures,sothatyoucouldevenuseitasthe
basisofacommercialsoftwareproduct.
Thecompletesourcecodeforthethumbnailgeneratorapplication,the


prototypes,andthefinalimageframeworkcanbefoundontheincluded
CD-ROM.Anyupdatestothesoftwarecanbefoundatthewebsite:
.


IntendedAudience
WeexpectyoutobefamiliarwithC++sothatwhenweapplyvarious
constructsfromthelanguage,youhaveseenorusedthembefore.We
alsoassumethatyouhavebuiltapplicationseitherforpersonalor
commercialuseandarefamiliarwithwhattheStandardTemplateLibrary
(STL)canprovide.Wehopetoengageyouindetaileddiscussionsofthe
advantagesanddisadvantagesofcertainC++constructs.Finally,we
hopeyoureallyliketolookatactualcodeexamples,becausethebookis
filledwiththem.
WedonotattempttoprovideareferencefortheC++language,butwe
doprovideprimersandreviewsofthosetopicsthathaveexactingsyntax
orarenotusedasfrequently.ForthebasicsoftheC++language,we
referyoutoTheC++ProgrammingLanguage,SpecialEdition

[Stroustrup00]Forin-depthdiscussionsoncertainC++constructs,such
asreferencecounting,wereferyoutoEffectiveC++,SecondEdition
[Meyers98].ForinformationontheStandardTemplateLibrary,werefer
youtoEffectiveSTL[Meyers01].ForinformationonusingC++
templates,wereferyoutoC++Templates[Vandevoorde03].
Asforourchosendomainofdigitalimaging,wedon'texpectyoutohave
anyexperiencewithwritingsoftwarethatmanipulatesimages.We
providesomebasicinformationaboutimagingthatyoucanreview;ifyou
arefamiliarwithimaging,youcanskipthatsection.Wheneverwetalk
aboutaparticularoperationthatweapplytoanimage,wetakethetime
togiveasimpleexplanation,aswellassomebeforeandafterpictures,
beforeproceedingtothecodeexample.Ifyouwantanin-depth,
mathematicaldiscussionofimageprocessingoperations,wereferyouto
DigitalImageProcessing[Pratt01].


HowtoUseThisBook
Thebookisintendedtobereadsequentially,sincethereisaconcrete
exampleintroducedinChapter2andusedtoevolvethefinaldesignof
theimageframeworkthatispresentedinChapter5.Throughoutthe
book,wehighlighttheC++techniquesweareexploringinheadingtitles
andinsummaryboxesthatappearonthefirstpageofeachchapter.
Thebookisorganizedasfollows:
Chapter1,Introduction,providesanoverviewofwhatwesetoutto
accomplishbywritingthisbook,andrevealsourbackgroundandbiases
astheyapplytotheC++techniqueswerecommend.Wealsoprovidean
optionalbackgroundsectionondigitalimaging.Ifyouhaveexperience
workingwithimagingapplications,youmaywanttoskipthefinalsection
ofthischapter.
Chapter2,ATestApplication,introducesoursimple,inadequate

application,usedasatestbedforprototypingC++techniques.We
deliberatelycreatethisstrikinglysimpleapplicationbecauseiteffectively
demonstratesthetrade-offsofvariousdesignandimplementation
decisions.
Chapter3,DesignTechniques,beginsourdiscussionofC++design.We
uselotsofcodeexamplestodemonstratedesignstrategies,andwe
provideaprimerontemplatessincetheyareusedsoheavilywithinthe
book.Finally,weprototypevariousaspectsofthedesignandbuild
generalutilitiesneededtosupportthedesign.
Chapter4,DesignConsiderations,exploresguidelinesandadditional
strategiesyoumaywanttouseinyourdesigns.Weofferapracticalset
ofcodingguidelines,reusabilitystrategies,andasimplebuteffective
debuggingstrategy.
Chapter5,SystemConsiderations,exploressystem-leveldesignissues,
likemulti-threadedandmulti-processdesigns,exceptionhandling


(includingaframeworkweprovideforhandlingexceptions),compiletime
andrun-timeissues,templatespecialization,andinternationalization
concerns.
Chapter6,ImplementationConsiderations,appliestheC++techniques
wehaveexploredtothefinaldesignandimplementationofallpiecesin
theimageframework.Inaddition,thischapterintroducesglobalimage
processingfunctions,likeedgesharpeningandnoisereduction,and
providesbothavisualoverviewofthesetechniquesandtheC++
implementations.Wealsoprovideahigh-levelinterfacetolibrariesand
otherthird-partysoftware.Specifically,weintroduceyoutotheIntel
IntegratedPerformancePrimitives(IPP)libraryandshowyouhowtouse
IPPforhigh-speedimagingapplications.
Chapter7,TestingandPerformance,providesareasonablestrategyfor

integratingunittestsintoyoursoftwaredevelopmentcycle,includinga
fullunittestframeworkandadiscussionofhowyoucanextendittomeet
yourparticularneeds.Wealsofocusonperformance,givingspecific
techniquesthatyoucanusetoimmediatelyimprovetheruntime
performanceofyourapplication.
Chapter8,AdvancedTopics,exploresthoseissuesthatwefeltwarranted
moredetaileddiscussion,suchascopyonwrite,caching,explicit
keywordusage,const,andpassbyreference.Wealsoincludea
sectiononextendingtheimageframework,toserveasaguidefortaking
theexistingframeworkandaddingyourownprocessingfunctions.We've
highlightedsomeroutinesthatworkparticularlywellforenhancingyour
digitalphotographs.
AppendixA,UsefulOnlineResources,provideslinkstothosesoftware
toolsandresourcesthatwethoughtmightbehelpful.
AppendixB,CD-ROMInformation,outlinesthecontentsoftheCD-ROM
includedwiththisbook.Thereisagreatdealofcodepresentedinthis
book.Allofthesourcecodeforourtestapplication,prototypes,and
imageframeworkisincludedonthedisc.Inaddition,weprovideallofthe
unittests,unittestframework,andmakefilesnecessarytorunthe
softwareonavarietyofplatforms.Wealsoincludesomeusefulthird-


partysoftware:thefreewareDebugViewutilitybySysInternalsfor
MicrosoftWindows,theevaluationversionoftheIntelIntegrated
PerformancePrimitives(IPP)libraryforMicrosoftWindowsandLinux,
theevaluationversionoftheIntelC++CompilerforMicrosoftWindows,
thesourcecodetobuildtheJPEGfiledelegate,andthesourcecodeto
buildtheTIFFfiledelegate.



ConventionsWe
Use

Isanavigationalaidethathighlightsatopicbeingdiscussed.

Theconventionsweuseinthis
bookareasfollows:

boldface Indicates
code.
italics

Highlights
anew
term.





Enclosesanobject'sdeclarationasitappearsinthecorresponding
headerfile.

Indicatesacodingpracticethatisnotrecommended.Theindicated
codemaybesyntacticallycorrect,butitmaybeinefficient,unsafe,or
problematicinotherways,asdiscussedinthecorrespondingtext.


Introducesoneofourtips.Tipscanbeeitherthingstodoorthingsnot
todo;theyarehighlightedtodrawyourattentiontoimportant

information.

//comments

Indicatesacommentinthecode.Intheinterestofbrevity,thecode
commentsthatweincludeinthebookdonotincludethefullcomments
thatarepresentinthesourcecode.TheCD-ROMcontainsthe
completesourcecode,whichisfullycommented.


Acknowledgments
Thisbookwouldnothavebeenpossiblewithoutthetremendous
encouragement,support,andhelpwereceivedfrommanypeople.We
thankyouallforyourtimeandpatience.
WewouldespeciallyliketothankDonaldD.Anderson,LouisF.Iorio,and
DavidLanznar,allofwhomspentenormousamountsofpersonaltime
reviewingandre-reviewingtheentiremanuscript.Yourinsightful
commentsandtechnicalexpertisehavemadethisabettertext.We
wouldespeciallyliketonoteDon'sinvaluablecontributionsandexpertise
intheareaofrun-timeissues.
Wearealsodeeplyappreciativeofthecomprehensiveandthorough
technicalreviewsandsuggestionsprovidedbyMaryDageforde,Steve
Vinoski,andJanChristiaanvanWinkel.Yourcarefulattentiontodetails
andpersistentcommentspushedustoimproveboththecodeandthe
manuscript.
Thefollowingpeoplealsomadetechnicalcontributionsonvarious
subjectsthroughoutthetext:NeilJacobson,BensonMargulies,Neil
Levine,ThomasEmerson,DavidParmenter,EvanMorton,andJohn
Field.Thankyou!
WefeelluckytohaveworkedwithsuchanincredibleteamatAddisonWesley,whoseprofessionalismanddedicationtoexactingstandards

encouragedustoundertakeandcompletethismanuscript:Debbie
Lafferty,PeterGordon,MikeHendrikson,BernardGaffney,JohnFuller,
TyrrellAlbaugh,ChandaLeary-Coutu,MelanieBuck,CurtJohnson,and
BethByers.
Finally,wethankTeamCheckpointforinspiringus.
PhilipRomanik,2003
AmyMuntz,2003


Chapter1.Introduction
EveryonewhousesC++,oranyprogramminglanguage,bringsalong
theirbiasesandexperiencestotheirsoftwaredevelopmentefforts.Inthis
book,wewillapplyC++tosolveproblemsinourchosenproblemspace
ofdigitalimaging.WhatbetterwaytoapplyC++constructsandseethe
immediateeffectsthanbymanipulatingdigitalimages,perhapsfromyour
owndigitalcamera.
Webeginwithasimple,inadequateapplicationthatgeneratesthumbnail
imagesfromdigitalpictures.Throughprototyping,wetestavarietyof
C++techniquesanddesignideasonthethumbnailapplication.Wethen
usewhatwelearnbyapplyingtheappropriateC++techniquestobuilda
robustimageframework,asshowninFigure1.1.

Figure1.1.DevelopmentRoadMap

Alongtheway,weexploresuchissuesas:What'sthebestwaytodesign
thisapplication,usinginheritanceortemplates?Shouldwedoeverything
atstaticinitializationtimeoruseaSingletonobject?Doesexplicit
templateinstantiationgiveusanysyntacticorfunctionaladvantages?
Doesreferencecountingusingrepobjectsandhandlesaddtothe
design?Howdowepartitionfunctionalitybetweenglobalfunctionsand

objects?Whatkindofframeworkmakessenseforhandlingexceptions?
Doestemplatespecializationhelpus?HowcanImakemyroutinesrun


faster?Wedon'tjustdiscusstheseissues;wewritelotsofcodetotest
ourassumptionsandtoexaminethetrade-offsinchoosingaparticular
application.
Ourbackgroundisindevelopingcommercialsoftware,thatis,software
withthefollowingcharacteristics:builtbymany,expandable,
maintainable,understandable,andstable.TheC++designand
implementationtechniquesthatweexploreareevaluatedintermsofall
ofthesecharacteristics:
Builtbymany:Softwarethatisbuiltbyateaminherentlymeans
thatnosinglepersonhasfirsthandknowledgeofallofthecode.It
alsomeansthatgoodcommunicationamongtheteammembersis
criticallyimportanttothesoftware'ssuccess.Communicationhasto
startatthebeginning;everyoneontheteammustsharean
understandingofwhatexactlyisbeingbuilt,forwhom,andwhenitis
needed.Byunderstandingthecustomersandtheirrequirements,
youcanalwaysgobackandaskyourself,"IsthisfeatureI'madding
reallynecessary?"Understandingboththebusinessandproduct
requirementscanhelpyouavoidthedreadedfeaturecreepor
increasingscopethatoftendelaysproducts.Communicationhasto
continuethroughouttheprocess:conveyinginterfacedesignssothat
integrationamongcomponentsrunssmoothly;accuratelyand
completelydocumentingyourcode;andconveyingnewmember
functionsandtheirpurposetotheSoftwareQualityAssurance(SQA)
andDocumentationgroups.
Expandable:Youmustbeabletoaddnewfeaturesquicklyand
extendexistingfeaturesincommercialsoftware.Theserequests

oftenseemtocomewhenaninfluentialcustomerfindsthatthey
needjustonemorethingtosolvetheirproblem.Evenworseiswhen
alimitationisdiscoveredonlyaftertheproductisreleased.Whether
ornotcodecanbeeasilyexpandedtoaccommodatetheserequests
isoftenafunctionofthedesign.Whileitmaybeaseasyasaddinga
newmemberfunction,significantnewfeaturesrequirethatthe
designbeextended.Putsimply,youhavetothinkaheadwhen


designingandwritingcode.Justimplementingtoaspecification,with
nothoughttofutureexpansionormaintainability,makesfuture
changesmuchmoredifficult.Afurthercomplicationisthatmost
softwarewon'tallowfeaturestobedeprecatedoncetheproductisin
use.Youcan'tsimplyremoveaclassthatwasillconceived,asitis
certainthatifyoudoso,you'llfindawholehostofcustomersusing
it.Backwardcompatibilityisoftenakeydesignconstraint.
Maintainable:Nomatterhowmanyunittestsarewritten,automated
testsarerun,orfunctionaltestsareexecuted,itisinevitablethat
bugswillbefoundaftertheproducthasbeenreleased.For
commercialsoftware,thegoalofalloftherigoroustestingand
preparationistoensurethatanypost-releasebugshaveminor
consequencestotheproduct.Whatbecomescrucialisthatthese
bugsbeeasilyandquicklycorrectedforthenextrelease.Itisalso
likelythatthepersonwhoimplementedaparticularcomponentwon't
bethepersonresponsibleforfixingthebug,eitherbecauseenough
timehaspassedthathehasbeenassignedtoadifferentproject,or
therearedesignatedengineersresponsibleforsupportand
maintenance.Giventheseconstraints,maintainabilitymustbe
designedintothesoftware.Therehastobeanemphasisonsolid
designpracticesandclarityincodingstyles,sothatthesoftwarecan

beefficientlymaintainedwithoutfurthercomplicatingit.
Understandable:Commercialsoftwareoftenincludesvisible
softwareinterfaces.Ifyouarebuildinganembeddedsystemlibrary,
itneedstobeunderstandabletotheapplicationengineerswithin
yourcompany.Ifyouarebuildingasoftwarelibrary,theinterfaceyou
presentmustbeeasilyunderstoodbyyourcustomerssothatthey
canuseittobuildtheirownapplications.Thisdoesn'tjustmeanthat
namingconventionsmustmakesense,butmoreimportantlythat
yourdesignandyouruseoflanguageelements,liketemplates,are
clearandappropriate.
Stable:Commercialsoftwaremustbestable;thatis,itmustbeable
torunforextendedperiodsoftimewithoutcrashing,leaking


×