NCF参数化建筑论坛

标题: processing handbook -- coding techinques [打印本页]

作者: weiwei    时间: 2010-10-15 15:09
标题: processing handbook -- coding techinques
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 執行就好,而是每一小部分的修改,累積起來的

作者: weiwei    时间: 2010-10-15 15:10
而且很少編碼人員是從頭開始寫程式的,通常是找到適合的模板,相互累加,在小部分的修改並擴大。 作者在文中也提及到,改變我對編程的一些基本觀念
作者: skywoolf    时间: 2010-10-15 16:39
恩,感觉有时候看编程貌似“嫁接代码”,gh的嫁接感也如此之明显。
作者: claudemit    时间: 2010-10-15 19:07
原来像拼贴艺术
作者: weiwei    时间: 2010-10-15 19:33
哈哈 誰拼的漂亮就是好程式了
作者: STL2000    时间: 2010-10-16 00:53
原来像拼贴艺术
作者: zcm_2004    时间: 2010-12-24 15:44
thanks, very good!
作者: suzhou    时间: 2010-12-25 23:17
都是英文!加油!好好看啦!
作者: bxsqrym    时间: 2012-4-25 11:44
这也可以。。。。同求
作者: 活建鬼    时间: 2012-4-25 12:21
先收藏下~~~~~~




欢迎光临 NCF参数化建筑论坛 (http://ncf-china.com/) Powered by Discuz! X3.2