Michaelwww.dizhi1.com

www.dizhi1.com  时间:2021-04-08  阅读:()
2007IEEE.
Personaluseofthismaterialispermitted.
However,permissiontoreprint/republishthismaterialforadvertisingorpromotionalpurposesorforcreatingnewcollectiveworksforresaleorredistributiontoserversorlists,ortoreuseanycopyrightedcomponentofthisworkinotherworksmustbeobtainedfromtheIEEE.
Formoreinformation,pleaseseewww.
ieee.
org/web/publications/rights/index.
html.
www.
computer.
org/softwareDoesBeautifulCodeImplyBeautifulDesignRebeccaJ.
Wirfs-BrockVol.
24,No.
6November/December2007Thismaterialispresentedtoensuretimelydisseminationofscholarlyandtechnicalwork.
Copyrightandallrightsthereinareretainedbyauthorsorbyothercopyrightholders.
Allpersonscopyingthisinformationareexpectedtoadheretothetermsandconstraintsinvokedbyeachauthor'scopyright.
Inmostcases,theseworksmaynotberepostedwithouttheexplicitpermissionofthecopyrightholder.
Intheshortpiece,"TreatingCodeasanEs-say,"YukijiroMatsumoto,chiefdesigneroftheRubyprogramminglanguage,com-pareswritingprogramstowritingessays:AccordingtoMatsumoto,themostimportantquestionacodereaderasksis,"Whatdoesitdo"Ifaprogram'spurposeisn'tclear,itisn'tgood,letalonebeautiful.
And,Matsumotoclaimsbrevityisoneofthemostimportantcon-tributorstobeautifulcode.
Althoughbrevitycancontributetocodebeauty—clarityofpurpose,expressiveuseoftheprogramminglanguage,anddesignelegancealsoplayapart.
ButistheremoretogooddesignthanbeautifulcodeBeautifulcode:Brevityvs.
fluencyToillustratehispointaboutprogrambrevity,Matsumotocontrasted"helloworld"aswritteninRuby(aswellasPerlandPython)—println"HelloWorld"—withtheequivalentJavacode(seefigure1).
TheJavaprogramisbulkierbecauseitin-cludestypeandclassdeclarationsandsyntac-ticelementsforspecifyingaccessrightstomethodsandvariables.
ButI'veseenplentyofJavacodethatreadswell.
ContrastingJavacodewithRubyillustratesthatstronglytypedlanguagescarrymorepro-grammingconstructsandrequirethatmorede-tailsbespecified.
Mostprogrammers,however,quicklyenoughbecomefamiliarwiththecom-plexitiesofthelanguagestheyprograminandcancreatereasonablecodeintheirlanguageofchoice.
Ofcourse,whenIfirstwanderintoanynewprogramminglanguage,myprogramslackelegancebecauseofmylimitedfluencyinthelan-guage.
Fluencydemandspracticeandobserva-tionofotherfluentprogrammerswhocansharewithyoutheircodeandreasonsforprogram-mingthewaytheydo.
Ifyou'rearoundotherswithmoreskillandpracticeinthatlanguage,andyoureadalotofgoodcode,youcanpickupalanguage'snuances.
Thishelpsyoudevelopaprogrammingstylethatfitswithinthelanguage'sconstraintsandexploitsitsstrengths.
AgreatC++programmightnotmatchmySmalltalksenseofaesthetics,butitstillcanbebeautiful.
Beautifuldesign:AddingcontextRecently,IparticipatedinagrandexperimentrunbyMichaelFeathersandEmmanuelGaillottoexplorewhetherso-calledexperts(thoseat-tendingaconference'sdiscoverysession)couldagreeonthemeritsofvariouscodesnippets.
Evenmoreambitiously,FeathersandGaillotwantedtodeterminehowtostructurecodeex-amplestohelpnovicesmorequicklydevelopanintuitivefeelforwhenasolutionisappropriate.
Afterscanningover100smallprogram-Forbothessaysandcomputercode,it'salwaysimportanttolookathoweachoneiswritten.
Eveniftheideaitselfisgood,itwillbedifficulttotransmittothedesiredaudienceifitisdifficulttounderstand.
Thestyleinwhichtheyarewrittenisjustasimportantastheirpurpose.
(BeautifulCode,O'Reilly,2007)18IEEESOFTWAREPublishedbytheIEEEComputerSociety0740-7459/07/$25.
002007IEEEdesignEditor:RebeccaJ.
Wirfs-BrockWirfs-BrockAssociatesrebecca@wirfs-brock.
comDoesBeautifulCodeImplyBeautifulDesignRebeccaJ.
Wirfs-BrockWhatbeautyis,Iknownot,thoughitadherestomanythings.
—AlbrechtDurerNovember/December2007IEEESOFTWARE19DESIGNmingsamplesinanhour,Ifounditin-creasinglydifficulttojudgewhetheranyparticularcodingexamplehadmerit.
SpottingquirkypartsthatwouldmakemegrumbleifIhadtomaintainthecodewasmucheasier.
Codethatlackedexpressivevariableandargu-mentnames,hadhardwiredconstants,hadpoorindentation,orwasfilledwithobscureprogramminghacksre-allyirritatedme.
WhatIfoundmostdisconcerting,however,wasthelackofanydesigncon-textforthecodeIread.
Withoutanymeaningfuldesigndiscussion,Ifeltadrift.
Ididn'tfeelconfidentratingasampleasgoodifIwasn'tcertainwhatitwasdoing.
AndanybadprogramminghabitsIspottedprovedincreasinglyan-noying.
Infact,mostcodesamplesweredevoidofmeaningfulcommentsthatcouldhaveshedsomelightonthede-sign.
Commentsthatwerepresentwerebanalorprivateasides.
Afterawhile,IbeganwonderingwhetherIwasharshwithmyjudgmentssimplybecauseIdidn'tunderstandthecode'spurpose.
OrmaybeIdidn'tlikethecodebecauseIwashopingtospotsomeineffableelegantcodingpatterns.
Thisexperimentconfirmedmybeliefthatoneofthebiggestmythsisthatwell-structuredcodeisself-document-ing.
Ifyoucan'tunderstandthesur-roundingdesigncontext,thepurposeofmostcodesnippetsisn'tobvious.
HabitablecodeRichardGabriel,inPatternsofSoft-ware(Oxford,1996),arguesagainstclarityorbeautyasanoverarchingsoftwaregoalandsuggestsinsteadthatweshouldstriveforhabitability:"thecharacteristicofsourcecodethaten-ablesprogrammers,coders,bug-fixers,andpeoplecomingtothecodelaterinitslifetounderstanditsconstructionandintentionsandtochangeitcom-fortablyandconfidently.
"Habitablecodeprovidesaplacewhere,Gabrielsays,"developerscanfeelathome,[and]placetheirhandsonanyitemwithouthavingtothinkdeeplyaboutwhereitis.
"Hebelievesthatclarityoftenprovestooelusiveandthatmostprogrammersandwrit-ersrarelydemonstratebrilliance.
Hesaysthatintricatelybeautifulcodeof-tenprovestooconstrainingtothemaintainerwhohastosustainallthatbeautyandelegancewhileaddingtoitafteritscreatorhasmovedon.
Havingworkedwithoverlyzealousframeworkdevelopers,Icanattesttosimilarfrustrationswithwhatseemedtomeunnecessarydesignembellishments.
ButI'veseenelegantframeworkstoo.
Theyusuallyaren'toverreachingintheirgoals;rather,theyprovidetheaffor-dancesneededtoextendandusethemwithoutmuchmentaleffort.
Inthechapter"FrameworkforInte-gratedTest:BeautythroughFragility"ofBeautifulCode,FeathersdiscussesthebeautyoftheflexibleyetconciseFITFramework.
Insteadofsupportingmul-tipleformatsfortests,FITsupportsjustHTML.
Eachframeworkclassisrela-tivelysimplebutdesignedtoletsome-oneeasilychangeit.
Allmethodsarepublicandthuschangeable.
FeathersclaimsthatthebeautyofFITisaconse-quenceofitbeingsmall,useful,andun-derstandable,yetopentochange.
That'sanexampleofsimplebeauty,butwhataboutinherentlymorecom-plexsystemsCancomplexsystemsbebeautifulForthelastcoupleofmonths,I'vebeenhelpingasmallteamrefactortheircode.
Theydidn'twanttobetheonlyoneswhocouldsustainit.
Theirsoftwareperformsexceedinglycom-plexcalculations,and,tocompoundtheirdesignchallenge,they'recon-stantlyaddingnewspecialcases.
Noth-Figure1.
"HelloWorld"writteninJava.
publicclassHelloWorld{publicstaticvoidmain(Stringargs[]){System.
out.
println("HelloWorld");}}20IEEESOFTWAREwww.
computer.
org/softwareDESIGNingevergoesaway,andtherequiredprocessingcomplexitykeepsincreas-ing.
Consequently,overtheyears,theircodehadgrownincrediblydenseandtangled.
Andtheyfounditincreasinglydifficulttoaddnewfunctionality.
Anybeauty,ifithadeverbeenpresent,hadbecomeobscured.
Althoughtheycouldn'tsimplifytheirprocessingre-quirements,theyhopedtosimplifyhowtheircodeworked.
First,theycleanedupaclasshierar-chythathadgrownsomewhatarcanebecauseofapreviousdesigner'sstylisticconventionthatresultedinextraneousclasses.
Next,theyreworkedthecodethatcontrolledtheprocessingtoclarifydecisionmakingandmaketheprocess-ingstepsmoreexplicit.
Finally,theytackledanovergrownclass,refactoringitintoacoupleofsmallerservicepro-viderclasseswithcarefullychosen,ex-pressiveclassandmethodnames.
Theresponsibilitiesofeachofthesesimplerclassesweremucheasiertounderstand.
Thedeveloperswerepleasedwiththeirefforts,becausetheyfeltthedesignintentwasmoreevidentintheirrefac-toredcode.
Whiletheresultingredesignwasn'tperfectlybeautiful(westoppedwhentheydeemeditgoodenough),thecodecertainlybecamemorehabitableasaresultofdesignreworkthatmadein-dividualclasses'responsibilitiessimpler,morestraightforward,andconsistent.
And,asanaddedbonus,theyreducedthenumberoflinesofcode.
Yettheirimplementationwasstillverycomplex.
Cancomplexdesignsthatareimple-mentedbycomplexcodeeverbecon-sideredbeautifulMostofusrecognizesimplebeautywhenweseeit.
Butfind-ingbeautyincomplexsystemsseemsmoredifficult.
Ittakestimetoappreci-atethecodebaseandunderstandthedesign.
Andifthereareglimmersofbeautyinplaces,thatbeautifulcodeisn'tnecessarilyunderstoodorappreciatedbythecasualreader.
It'shardtoscalefunctionality,pre-serveadesigner'sintent,andkeepasys-tembeautiful(ifindeediteverwas)whencontinuallyaddingbehaviors.
Butwhenthedesigner'sintentbecomeslost,it'shardtofindmuchbeauty,evenifthere'sabrilliantlycodedmethodortwo.
Aglimmerofdesignbeautyispreservedincomplexsystemswhenresponsibilitiesarereasonablyfactoredamongdesignel-ementsandthebehaviorofanyindivid-ualclassormethodiscomprehensible—givenyouknowthedesigncontext.
IlooktocreatedesignsolutionsthatreflecttheneedsofthosewhowillsustainthecodeafterImoveon.
Agooddesignismorethancleanly,clearly,andconsistentlyexpressedcode.
Beautifulcodeisbeautifulonlyifitpreservesandmakesevidentthede-signer'sintent.
Whatwasonceagooddesignoftendegradesasnewfunction-alityisadded.
Itwouldbegreattothrowcodeawayandrebuilditaneweveryfewyears,butthat'snotpracti-cal.
Instead,weshouldstrivetomakeourcodehabitable.
Ifwedo,we'llpre-servethebeautyandelegancethatdoesexistinourdesignsawhilelonger.
Arecomplex,pragmaticsolutionstocom-plexproblemseverbeautifulIsup-poseitalldependsonwhataestheticsyouapplyinjudgingbeauty.
RebeccaJ.
Wirfs-BrockispresidentofWirfs-BrockAssociates.
Contactheratrebecca@wirfs-brock.
com;www.
wirfs-brock.
com.

这几个Vultr VPS主机商家的优点造就商家的用户驱动力

目前云服务器市场竞争是相当的大的,比如我们在年中活动中看到各大服务商都找准这个噱头的活动发布各种活动,有的甚至就是平时的活动价格,只是换一个说法而已。可见这个行业确实竞争很大,当然我们也可以看到很多主机商几个月就消失,也有看到很多个人商家捣鼓几个品牌然后忽悠一圈跑路的。当然,个人建议在选择服务商的时候尽量选择老牌商家,这样性能更为稳定一些。近期可能会准备重新整理Vultr商家的一些信息和教程。以前...

Virtono:圣何塞VPS七五折月付2.2欧元起,免费双倍内存

Virtono是一家成立于2014年的国外VPS主机商,提供VPS和服务器租用等产品,商家支持PayPal、信用卡、支付宝等国内外付款方式,可选数据中心共7个:罗马尼亚2个,美国3个(圣何塞、达拉斯、迈阿密),英国和德国各1个。目前,商家针对美国圣何塞机房VPS提供75折优惠码,同时,下单后在LET回复订单号还能获得双倍内存的升级。下面以圣何塞为例,分享几款VPS主机配置信息。Cloud VPSC...

Virmach($7.2/年)特价机器发放

在八月份的时候有分享到 Virmach 暑期的促销活动有低至年付12美元的便宜VPS主机,这不开学季商家又发布五款年付VPS主机方案,而且是有可以选择七个数据中心。如果我们有需要低价年付便宜VPS主机的可以选择,且最低年付7.2美元(这款目前已经缺货)。这里需要注意的,这次发布的几款便宜年付方案,会在2021年9月30日或者2022年4月39日,分两个时间段会将INTEL CPU迁移至AMD CP...

www.dizhi1.com为你推荐
小度商城小度智能屏Air哪里可以买?大家都怎么入手的?摩根币摩根币是什么意思?百度商城百度知道一般一天能挣多少钱?商标注册流程及费用注册商标的流程是什么,大概需要多少费用?firetrap我淘宝店还是卖二单就被删,怎么回事!西部妈妈网啊,又是星期天西部妈妈网九芽妈妈网加盟费多少bbs.99nets.com怎么制作RO单机罗伦佐娜手上鸡皮肤怎么办,维洛娜毛周角化修复液同ip域名两个网站同一个IP怎么绑定两个域名
西安服务器租用 过期域名查询 申请免费域名 老左 a2hosting ix主机 外国空间 2017年黑色星期五 商家促销 华为4核 本网站服务器在美国 百兆独享 200g硬盘 上海电信测速网站 我的世界服务器ip 电信网络测速器 酸酸乳 测速电信 阿里dns 后门 更多