Tải bản đầy đủ - 0 (trang)
Chapter 4.  Invest in code reviews

Chapter 4.  Invest in code reviews

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

Summary

Re-viewcode:Moreeyeswillhelpmakemorequality.Show

yourcode,andreadothers'.You'llalllearnandbenefit.



Discussion

Agoodcodereviewprocessbenefitsyourteaminmanyways.

Itcan:

Increasecodequalitythroughbeneficialpeerpressure.

Findbugs,non-portablecode(ifapplicable),andpotential

scalingproblems.

Fosterbetterdesignandimplementationthroughcrossbreedingofideas.

Bringnewerteammatesandbeginnersuptospeed.

Developcommonvaluesandasenseofcommunityinside

theteam.

Increasemeritocracy,confidence,motivation,and

professionalpride.

Manyshopsneitherrewardqualitycodeandqualityteamsnor

investtimeandmoneyencouragingthem.Wehopewewon't

havetoeatourwordsacoupleofyearsfromnow,butwefeel

thatthetideisslowlychanging,dueinparttoanincreased

needforsafeandsecuresoftware.Codereviewshelpfoster

exactlythat,inadditiontobeinganexcellent(andfree!)

methodofin-housetraining.

Evenifyouremployerdoesn'tyetsupportacodereviewing

process,doincreasemanagementawareness(hint:tostart,

showthemthisbook)anddoyourbesttomaketimeand

conductreviewsanyway.Itistimewellspent.



Makecodereviewsaroutinepartofyoursoftwaredevelopment

cycle.Ifyouagreewithyourteammatesonarewardsystem

basedonincentives(andperhapsdisincentives),somuchthe

better.

Withoutgettingtooformalistic,it'sbesttogetcodereviewsin

writingasimplee-mailcansuffice.Thismakesiteasiertotrack

yourownprogressandavoidduplication.

Whenreviewingsomeoneelse'scode,youmightliketokeepa

checklistnearbyforreference.Wehumblysuggestthatone

goodlistmightbethetableofcontentsofthebookyouarenow

reading.Enjoy!

Insummary:Weknowwe'repreachingtothechoir,butithad

tobesaid.Youregomayhateacodereview,butthelittle

geniusprogrammerinsideofyoulovesitbecauseitgetsresults

andleadstobettercodeandstrongerapplications.



References

[Constantine95]Đ10,Đ22,Đ33[McConnell93]Đ24

[MozillaCRFAQ]



DesignStyle

Foolsignorecomplexity.Pragmatistssufferit.Some

canavoidit.Geniusesremoveit.

AlanPerlis

ButIalsoknew,andforgot,Hoare'sdictumthat

prematureoptimizationistherootofallevilin

programming.

DonaldKnuth,TheErrorsofTeX[Knuth89]

It'sdifficulttofullyseparateDesignStyleandCoding

Style.Wehavetriedtoleavetothenextsectionthose

Itemsthatgenerallycropupwhenactuallywritingcode.

Thissectionfocusesonprinciplesandpracticesthatapply

morebroadlythanjusttoaparticularclassorfunction.A

classiccaseinpointisthebalanceamongsimplicityand

clarity(Item6),avoidingprematureoptimization(Item

8),andavoidingprematurepessimization(Item9).Those

threeItemsapply,notjustatthefunction-codinglevel,

buttothelargerareasofclassandmoduledesign

tradeoffsandtofar-reachingapplicationarchitecture

decisions.(Theyalsoapplytoallprogrammers.Ifyou

thinkotherwise,pleaserereadtheaboveKnuthquoteand

noteitscitation.)

Followingthat,manyoftheotherItemsinthisandthe

followingsectiondealwithaspectsofdependency

managementacornerstoneofsoftwareengineeringanda

recurringthemethroughoutthebook.Stopandthinkof

somerandomgoodsoftwareengineeringtechniqueany

goodtechnique.Whicheveroneyoupicked,inonewayor

anotheritwillbeaboutreducingdependencies.



Inheritance?Makecodewrittentousethebaseclassless

dependentontheactualderivedclass.Minimizeglobal

variables?Reducelong-distancedependenciesthrough

widelyvisibledata.Abstraction?Eliminatedependencies

betweencodethatmanipulatesconceptsandcodethat

implementsthem.Informationhiding?Makeclientcode

lessdependentonanentity'simplementationdetails.An

appropriateconcernfordependencymanagementis

reflectedinavoidingsharedstate(Item10),applying

informationhiding(Item11),andmuchmore.

OurvoteforthemostvaluableIteminthissectiongoesto

Item6:Correctness,simplicity,andclaritycomefirst.

Thattheyreally,reallymust.



5.Giveoneentityonecohesive

responsibility

Summary

Discussion

Examples

References



Summary

Focusononethingatatime:Prefertogiveeachentity

(variable,class,function,namespace,module,library)onewelldefinedresponsibility.Asanentitygrows,itsscopeof

responsibilitynaturallyincreases,butitsresponsibilityshould

notdiverge.



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

Chapter 4.  Invest in code reviews

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

×