Modification
Changing the values of variables in existing programs is a good way to explore code.Programs can be modified by trial and error or more deliberately. One way to start understanding a program is to change slightly the value of one variable and then runthe code to see the result. If there is no obvious difference, change the value again.Making the correlation between a variable and a change in the way a program runs is a good first step to understanding how it works.These modification techniques aid in learning new skills or parsing an example. Making small changes toan existing program encourages exploration and getting a feel for the code.
Augmentation
Augmentation uses existing code as a base for further exploration. It is similar to but more ambitious than modification. Generic program examples can serve as a foundation for longer, more specific programs.
Collage
The collage technique involves cutting and pasting elements of different programs together to create a new program. It’s analogous to creating music by sampling ormaking a visual collage from newspaper and magazine clippings. In order to avoiderrors, combine code carefully by copying a few lines of code at a time and runningthe program to make sure it’s always working. Copying large portions of code canintroduce a number of simultaneous errors. Mindlessly copying and pasting code cancreate “Frankenstein” code that’s difficult to debug.
Coding from scratch
Rarely do programmers write a complete program entirely from scratch. At theminimum, most people start with a template. A template is an outline with codeinfrastructure common to many programs. Sometimes it’s not possible to fi nd a relatedexample or appropriate template and it’s necessary to start with a blank page.
Regardless of the technique used for programming, writing a few lines of code or
making only a few changes at a time is a good tactic. Entering many lines of untested
code before running the program increases the potential for multiple errors. The more
errors in a program, the more difficult they become to find. Running a growing program
piece by piece reduces the chance for multiple errors. As your comfort with code and
your skills increase, it becomes possible to make more modifi cations between tests.
資料 來源 processing handbook --p145
程式編碼的重要概念 !!! 4大原則 ,程式不是copy 在past 執行就好,而是每一小部分的修改,累積起來的