Programming MethodologyLecture05.docx
- 文档编号:24476003
- 上传时间:2023-05-27
- 格式:DOCX
- 页数:27
- 大小:34.86KB
Programming MethodologyLecture05.docx
《Programming MethodologyLecture05.docx》由会员分享,可在线阅读,更多相关《Programming MethodologyLecture05.docx(27页珍藏版)》请在冰豆网上搜索。
ProgrammingMethodologyLecture05
ProgrammingMethodology-Lecture05
Instructor(MehranSahami):
Allrighty.Let抯goaheadandgetstarted.Acoupleofquickannouncementsbeforewestarttoday?
sohopefullyyou抮eallbusyworkingawayonKarelandlifeisgood.Justquickpoll?
howmanypeoplehaveactuallyfinishedKarelalready?
Oh,yeah.Iwon抰askhowmanypeoplehavenotyetdownloadedEclipse.Therearenohandoutstoday.Getting?
alittlebreather?
nohandouts.Don抰worry;you抣lgetsomemoreofthatnexttime.
Sectionsstartthisweek,sohopefullyyouallshouldhavegottenanemailaboutyoursectionassignmentandwhoyoursectionleaderis,soyoucanactuallydoAssignmentNo.1,theemailportion.Youshouldhavebeenabletodotheprogrammingportionthewholetime.Butmakesuretogotosectionthisweek.
AndtheotherthingistheTresidderLayer,whicheveryonceinawhileyou抳eheardmereferto.ThisisacomputerclusterupinTresidder.Isstaffedbyoneofsixhelperslikealmostcontinuouslyaroundtheclockormostofthetimesatreasonabletimeswhenpeopleareworking.
SoSundaythroughThursday,everydayexceptFridayandSaturdaybecausecontrarytopopularopinion,computersciencepeopleactuallydohavelivesorweactuallyliketopretendwehavelives,buteverydayfromSundaythroughThursday6:
00p.m.tomidnighttherewillbeastaffofhelpersonthereandactuallysomeofthetimesthereisliketwoorthreeorfourpeoplethere.
Andthey抮etherejustdedicatedforthe106classes.They抮enotlikegeneralconsultants.They抮ejusttheretohelpyouworkoutproblemsinthisclass,andtheyknowlikewhatassignmentsyou抮eworkingon,thewholedeal.They抮ealllike,yoursectionleadersandthey抮eallbeexceptionallytrainedtodothis.
Theotherthingthat抯goingon,hopefullyyoushouldbedoingAssignmentNo.1.I抳eactuallygottenabunchofAssignmentNo.1emailsthathavealreadycomein.Intheearlydays,whenIgotthefirstfew,Iactuallytriedtorespondtothemall,butthenatsomepoint,IjustwokeupandIlike,youknow,wenttomycomputerandwaslike,揙h,you抳egotmail.?
Anditjust[inaudible].SoIcouldn抰respondtoeveryoneindividually.IapologizeifIdon抰respondtoyouindividually,butIdoreadthemall.IguaranteeyouthatIactuallyreadthemallandIlookatbackgrounds.AndjusttoprovetoyouthatIdo,here抯someinterestingonesthathavecomeinsofar?
justtosharethree.
Sothere抯someoneactuallyspenttheirtimeinTaiwanlivinginaBuddhistmonastery,whichIthoughtwasinteresting,exceptforthefacttheywereactuallylivingthereasamonkwhomIthoughtwasprettyinteresting.
Someoneelseuseda?
Iwasn抰quitesureonthisconcept,butmaybeIcanprovideaclarification.Therewasavegetarianwhoonlyeatslow-qualitymeat,andsohementionedthatasthingslikeburgersandnotsteaks.AndIwouldqualifythatbysayingthat抯notavegetarian;that抯calledbeingagradstudent.
Andlast,butnotleast,therewasactuallysomeoneinherewho抯ontheColbertReport,whichIthoughtwasactuallyprettyinteresting.Idon抰knowinwhatcontext,butcometalktomeafterwards.
Sowiththatsaid,anyquestionsaboutanythingbeforewestart?
Todaywe抮eactuallygonnagooversomeofthegraphicstuffyousaw,talkalittlebitmoreaboutobjectsandclassesandgetintovariablesandvaluesandallkindsofgoodies.Anyquestions?
Allrighty,thenlet抯justdiverightin.Sooneofthemaintopicsfortodayisthisthingcalledavariable.Andavariable,youknow,likevariablescomeupinmathematicsandit抯like,ohXandYarevariables,rightandtherearethesethingsandwedoallthesemanipulationsonvariables.
Inthecomputerscienceworld,they抮ereallyfriendly,right,andyoudon抰havetoworryaboutintegrationordifferentiationoryouknow,thosekindofvariables.Variablesarekindofyourfriend,andbasicallyallthevariableisinthecomputerscienceworldsisit抯abox.It抯aboxwherewestickstuffandthestuffwestickintothatboxcanchange.
That抯whywecallitavariablebecauseit抯aboxthathasavariablecontents,andyouthinkbackyouknow,inthedaysofyoreinmath,andyouknow,ohyeah,it抯kindoflikeXcanhavedifferentvalues,yeah,it抯basicallyjustlikethat.
Soincomputerscience,whatwethinkofasavariable,iseachvariablehasthreethingsassociatedwithit.It抯gotsomename,andthat抯justhowwerefertothatparticularbox.Ithasatype,whichissomethingalittlebitdifferentinmathematics,butthetypebasicallysayswhatkindofthingdoesthisboxstore?
Someboxesstorenumbers;someboxesstoreletters;someboxeswillstoreotherthings,likelittleobjectsintheworld.Butatypeisjustwhat抯storedinthatbox.
Andthenthere抯avalue,andthevalue,asyoucanimagineisjustwhat抯inthebox.Whatistheactualthingthat抯inthere,right?
Ifitstoresthenumber,thenitmightstore,forexample,theValue3andthat抯justthevalue,anditmayhavesomenameassociatedwithit.
Andhowdoweactuallynamethese?
There抯actuallyaruleandit抯notaverycomplicatedrule,butaverysimpleruleyouneedtorememberforwhatarevalidnamesforvariablesinJava.Soavalidname,sothisishowyouactuallynamethesepuppies,hastostartwithaletteroranunderscore.Soitstartswithaletterlikeoneofthealphabeticlettersandcanbeupperorlowercaseortheunderscorecharacter.
Okay,andthat抯kindofyouknow,underscore.It抯downatthebottomoftheline,okay?
Andthenafteryouhavethatinitialletterorunderscore,thenafterthat,youcanhaveanynumberofletters,numbers,that抯likethenumberdigits,like1,2,3,4,youknow,0,etc.orunderscores,okay?
Soyoucan抰startwithanumber.Youhavetostartwithaletterorunderscore,butformostpurposesinthisclass,justthingaboutthemasletters.Whennotactuallyusingunderscores,youmightoccasionallyusenumbers.Youcanactuallyhavenumbersafterthefirstletter.
Thereisoneslightcaveattothisrulewhichyoucan抰haveanyvariablesthat抯nameisthesameassomewhichknownasareservedwordinJava,whichmeansitsnamecan抰bethesameassomespecialwordinJava,likethewordclassisaspecialnameinJava,andthere抯actuallyapageinyourbook,IthinkinChapter2,thatlistsallthespecialnames.It抯likeoutoftheEnglishlanguageithasabout127,000words.Ithinkthereislike40inJavathatyoucan抰makeavariablename.
Okay,youhavelotsofotherchoices.Asamatteroffact,there抯lotsofthingsthatdon抰havetobevalidwordsinEnglish.Theycanjustbeanynamethatfollowsthisrule.Theimportantthingtothinkaboutintermsofanameandthisisoneofthegoodsoftwareengineeringprinciples,ismakeyournamedescriptive.Ifyouhaveaprogramthat抯maintainingforexample,thebalanceinthebankaccount,arealgoodnamefortheplacewhereyoustorethevalueofthebalancewouldbesomethinglike揃alance.?
Arealbadnamewouldbesomethinglike揂,?
becausenooneknowswhatAis.It抯likeheyit抯A?
yeah,IknowwhatAis.Andsomeonesays,揧eah,Aisbalance,?
andsomeonesays,揘o,no,no,inmyprogram,AisactuallyhowmanymilesIbicycletoday,?
andyou抮elike,揘o,no,no,man,Awasbalanced.?
Well,ifit抯calledBalance,there抯justnoambiguity,sogivethemdescriptivenames.
Sothat抯kindofanamepartofthis.Thenextthingiswhatisthistypeallabout.Whatarethedifferenttypesthatyoucanactuallyhave.Andtherearesomethingsthatwerefertoasprimitivetypes.Thesearethetypesthathavethesmallerdevelopedbrainsanduseknucklesdragontheground.No,therejustthetypesthatarebuiltintoJava,okayandsomeofthebasictypeswehaveissomethingwecallanINT,whichisshortforaninteger,butweactuallywriteINT,soINT,I-N-T,isthenameofthetype,okay.
Andthisisjustanintegerofvalue.It抯justgonnastoresomewholenumberbasically.Itstoresanumberbetweenminus2billionandplus2billion,butforallintentsandpurposes,youcanjustimagineyoucanstoreanyintegerinthere,okay?
There抯alsobesidesintegerswhatotherkindsofnumericdatadowehave?
Peoplealreadyknow,it抯likeIwouldthinkitwouldbelikerealvalues,butabunchofpeoplearealreadysayingdoublebecauseyou抳ereadaheadandyou抳edonetheassignmentthewayyoushould.Andthatwaskindofaminisocial,butbothwenttothesameperson.
There抯thisthingcalledadoubleandadoubleisactuallysomerealvaluednumericvalue,right.It抯somethinglike2.3isadoubleoreven2.0canbeadouble,okay?
Whyisthisthingcalledadouble?
anyoneknow,asopposedtolikeareal?
Uh-huh?
Student:
[Inaudible].
Instructor(MehranSahami):
Yeah,there抯thiswonderfulverbpeoplecalltheItripleE,whichisliketheInstituteforElectricalandElectronicEngineersandtheycomeupwithallthesestandardsforthings.IsanyoneamemberofITripleEhere?
Noone?
Oh,man,joinandpayyourdues.It抯agoodtime.I'mnotactuallyamembermyself.
Butwhatthosefolksactuallydoistheycomeupwithstandardsforthingsandoneofthestandardstheycameupwithishowyourepresentnumbersthatarerealvaluednumbersinsideacomputer,right,becauserememberacomputeronlyunderstandsonesandzeros,sohowdoyouactuallyrepresentarealvaluednumber.
Andsothere抯astandard,andpartofthatstandardhastodowithaprecisionofthenumber,howmanydigitsinsomesenseandaroughapproximationyoustoreanddoublestandsforadoubleprecisionrealnumber.
Andsoforthepurposeofthisclass,allrealvaluednumbersthatwe抮egonnausearejustoftypedouble.Okay,there抯acoupleofothertype
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Programming MethodologyLecture05