Block-based coding - Coding: A Practical Guide - Subject ...
文章推薦指數: 80 %
Want to code without typing (virtually) anything? Block-based coding means that instead of typing a coding language, you drag and drop jigsaw- ...
SkiptoMainContent
LibrarySubjectGuidesCoding:APracticalGuideBlock-basedcoding
SearchtheseGuides
Search
Coding:APracticalGuideBlock-basedcoding
HomeIntroductiontocodingCodinglanguagesToggleDropdownBlock-basedcodingPythonHTMLandCSSJavaScriptProcessingandp5.jsGoogleAppsScriptRSpreadsheets?!TroubleshootingyourcodeDesigningforusersVersioncontrol
Block-basedcoding
Wanttocodewithouttyping(virtually)anything?
Block-basedcodingmeansthatinsteadoftypingacodinglanguage,youdraganddropjigsaw-likepiecestogethertobuildthingsusingtoolslikeScratchorThunkable.
Howdoesblockbasedcodingwork?
Block-basedcodingworksbydraggingtogether'blocks'ofcodetomakeprogramsthatcandothings.Therewillbearangeofdifferentkindsofblocksthatcanbeused,andoftenthesehavehints(aswithajigsaw)onwhichwillfittogether.
BelowisanexampleofsomecodefromThunkable,atoolthatallowsyoutomakesimpleapps.Thedifferentcoloursoftheblocksshowtheirdifferentfunctions:theyellowblockisan'event',lookingforwhenabuttonisclicked,andthenthepurpleblockconnectedtoitisasoundblock,andwillplayasoundwhentoldtobytheyellowblock.
AnexampleofThunkablecodetoplayasoundwhenabuttonispressed.
Featuresofblock-basedcoding
WhetheryouuseScratch,Thunkable,oranotherblock-basedcodingtool,theytendtohavesimilarfeatures,mostlybasedaroundcodingconceptsthatyou'llfindintypedcodinglanguagesaswell.
Theyalltendtorevolvearoundtwoelements:creatingthevisualinterfacethattheuserwillinteractwith,andputtingtogethertheblocksthatmakeupthecode.
Designingtheinterface
Whetheryou'remakingagame,anapp,oranythingelse,you'redesigningitwithsomeoneinmind,andthey'llneedawayofinteractingwithit.Thisistheinterfaceandhasdifferentnamesdependingonthetoolyou'reusing:inScratch,forexample,it'scalledthe'stage',whereasThunkableusesdifferent'screens'inamainDesignarea.
You'llneedtodesignthevisualsandanyfeaturesthatneedtoexistintheinterface.Thesemightbethingstheuserneedstoclickon(likebuttons),visualelements(likebackgrounds),orcontent(liketext).Thinkaboutwheretheseneedtoappear,whattheyneedtolooklike,andifyouneedtosetanythingelse(likewhetherornottheyappearatfirst).
Makingthecoderun
Wheneveryou'recreatingcodetomakeacomputerdosomething,itdoesn'tjustknowwhattodo:italsoneedstoknowwhentodoit.Codehastoberun,whichisonewayofsayingthatthecomputerfollowsthoseinstructions,andusuallythisisdonebytellingthecomputeraruleforwhenitshouldrun.
Inblock-basedcoding,thistendstobeusingeventblocks,whichareblocksthattellthecomputerwhich'event'mustoccurforthecodetorun.Theseeventsarelikelytobethingsliketheuseropeningtheapp,pressingabutton,orusinganotherfeature.
Soyoumighthaveablockthatsays'whenbuttonispressed'andthenyoucanconnectotherblockstoitthatsaywhathappenswhenthatbuttonispressed.
Thunkable
Thunkableisablock-basedcodingtoolforcreatingsimpleinteractiveapps,suchaslittlegames.Itcanalsobeusedtoaddfeaturesliketext-to-speechandimagerecognition,asithasblockswithspecificfeatures.
It'sgoodforprototypingideasandthinkingaboutwhatyoumightneedtomakeanappwork,withouthavingtolearnoneofthecodinglanguagesusedtodevelopapps.
It'salsousefulforthinkingabouthowyoumakeanappfunctionalforyourusers,asyoucanlivetestyourappwithinyourwebbrowsertotryoutthefeaturesyougiveit.
FullThunkableslidesonGoogleSlides
KeyfeaturesofThunkable
Thunkablehastwosections:DesignandBlocks.
Designiswhereyoucreatetheuserinterfaceforyourapp:whattheuserseesandinteractswith.Dragcomponentslikebuttons,labels,andtextentryfieldsontothescreensandcustomisetheattributesofthesesotheylookhowyouwant.
Blocksiswhereyoucreatethecodethattellsyourapphowtofunction.Draganddropblockstogethertoformcode,setsofinstructionsforthecomputer.
Whenyou'reworkinginDesign,you'lladdcomponentstoscreens,whicharethedifferentscreensuserswillseeintheapp(abitlikedifferentwebpages).You'llalsoneedtoaddnavigationcomponents,eitherthroughthebuilt-innavigatoroptionsorbycodingbuttonssotheywillgotoanotherscreen.
Whenyou'reworkinginBlocks,therearedifferentcategoriesofblocksthatcanbeputtogether.Theshapesandcolourssuggestionwhatkindofblocktheyareandwhichotherblockstheymightbeabletoconnectto.
UIcomponentsblocksareonesthatcontrolthecomponentsyouaddedintheDesignsection.Forexample,youmightfindblocksthatallowyoutotellthecomputerwhattodowhenabuttonispressedortogetthetextenteredinatextentryfield.
ControlblocksallowyoutocontrolwhatthecodedoesusingcommoncodingcommandslikerepeatingactionsandmakingIFdecisions.
Variableblocksarehowyoucancreatevaluesthatarestoredinthecomputer'smemoryandreferencedbytheirname.Thesecanbeanyvalueyouneedtouseagaininyourcode,likeascoreorwhatauserentered.
GroupsofblockslikeMath,Text,Lists,andColorblocksarehowyoucanworkwithdifferentkindsofvalues,likedoingcalculations,manipulatingtextandlistsofvalues,andchangingcolours.
AppFeaturesblocksallowyoutoaccessmoreadvancedfeaturesforyourapptouse,likegeneratingorrecognisingspeechoraccessingthedevice'scamera.
DesigningtogowithourThunkableworkshop,theseexercisesgetyoubuildingadualpurposeappthatcansaywhatausertypesandalsotranslatewhattheytype-withouttypinganycode!
Thunkableexercises
Scratch
Scratchisablockbasedcodingtooldesignedforbeginnersandeducationcontexts,whichallowsyoutocreategames,animations,andinteractivestories.
Scratchallowsyoutocontrolthingsonthescreen,suchasgettingthespritetomoveorasoundtoplay.
TouseScratch,yousignupforafreeaccountonScratch'swebsiteandthenstartbuildingcodeinyourwebbrowser.Youcancreateyourowncodingprojectsorviewand'remix'otherpeople'stoseehowtheywork.
Scratchhassomeofitsowntutorials,oryoucanuseourScratchmaterialsbelowtogetstartedusingit.
FullCodingwithScratchslidesonGoogleSlides
CodingwithScratchcheatsheet(andguidetoblocks)
IfyouwanttotryoutfirstlookingatScratchprojects,tryingoutbuildingone,andthenthinkingupyourownideas,thisScratchexercisesheetwillgiveyouthepromptstomovefromexploringothercreationstomakingyourown.
CodingwithScratchexercises
Elsewhereonthepage,you'llfindtheresourcesandexercisesforlearningScratchandThunkable,ifyouwanttotryouteitherofthem.
Ifyouwanttotryoutblock-basedcodingwithacreativefocus,we'vealsodevelopedasessionforcreatingapointandclickgameinScratch.Workthroughtheslidesandthenusethewalkthroughtocreateagamethatyoucanthenstarttoadaptifyouwant!
'Createagame'slides
HowtocreatetheLibraryHuntergameinScratch
Whattodonext
Onceyou'vehadagolearningScratchorThunkable,youmightwanttobuildmorecomplexthingswiththem,ormoveontoatypedcodinglanguage.
Bothtoolshavetheirowntutorials,whichgetharderindifficultyandareworthtryingout.Otherwebsitescanhavefreetutorialsandcoursestoo,sometimesaimedathowtoteachthetoolstochildren.
Oryoumightwanttoapplyyourknowledgetoanothercodinglanguage.Checkouttheothercodinglanguagesonthisguideandthinkaboutwhatyouwanttodowithcoding.YoumightwanttofurtheryourgamesbybuildingthemnotinScratch,butinsomethingelse.OnFutureLearnthere'safreecourseonhowtomovefromusingScratchtousingPythonwhichmightgiveyousomeideas.
IfThunkablemadeyoumoreinterestedinmakingapps,youmightwanttoresearchonlinewhichcodinglanguagesmighthelpyoumakethekindofappyou'reinterestedin.Lotsofcommoncodinglanguagesarealsousedforappdevelopment.
<
延伸文章資訊
- 1Microsoft MakeCode for micro:bit
About... New? Start here! Start Tutorial ... Tutorials for the new micro:bit (V2). Pet Hamster .....
- 2BlockPy – Introductory Python Programming Blockly ...
BlockPy – Introductory Python Programming Blockly Environment. Whilst looking around to see what ...
- 3Block-based coding - Coding: A Practical Guide - Subject ...
Want to code without typing (virtually) anything? Block-based coding means that instead of typing...
- 4Book - 3.6) Python in BlockPy: Intro to Computational Thinking
Using block-based programming is a good first step to learn about programming ... and there are m...
- 5Welcome to BlockPy! - Virginia Tech
BlockPy is a web-based Python environment that lets you work with blocks, text, or both. Designed...