在**無瑕的程式碼(Clean Code)**這本書,第一章就說到:
沒有辦法不先讀程式碼就去寫程式,所以讓程式碼更容易閱讀,也會讓程式碼變得更容易撰寫。
可見得寫出令人容易閱讀的程式是一件多麼重要的事,一位專業的程式設計師就是能寫出讓人一目瞭然的程式碼。
What Makes Code Readable: Not What You Think在這篇文章,提到寫出可讀性高的程式碼,有下列幾個標準答案:
(function() { | |
/* | |
* BaseTestCase class | |
*/ | |
function BaseTestCase(name) { | |
this.name = name; | |
this.func = []; | |
} | |
/* |
in_file = file('some_file','rb'); | |
out_file = file('some_file_decode','wb'); | |
exchange = (lambda x: chr((lambda h:(ord(h)%16)*16)(x)+(lambda l:(ord(l)/16))(x))); | |
in_file.seek(0,2); | |
counter = in_file.tell(); | |
in_files.seek(0,0); | |
while counter>0: | |
out_file.write(exchange(in_file.read(1))); | |
counter-=1; | |
in_file.close(); |
#coding: utf8 | |
import wsgiref.handlers; | |
from sgmllib import SGMLParser; | |
from google.appengine.ext import db; | |
from google.appengine.ext import webapp; | |
from google.appengine.api import users; | |
from google.appengine.api import urlfetch; | |
class Files(db.Model): |
import processing.serial.*; | |
Serial port; | |
int x; | |
float val; | |
float easing = 0.1; | |
float easedVal; | |
void setup(){ | |
size(440,255); | |
frameRate(30); |
//A0 - input pin | |
int fsrPin = 0; | |
byte fsrReading; | |
void setup(){ | |
pinMode(fsrPin,INPUT); | |
Serial.begin(9600); | |
} | |
void loop(){ |
//A0-input pin | |
int fsrPin = 0; | |
int fsrReading; | |
double fsrVoltage; | |
double fsrResistance; | |
double fsrConductance; | |
double fsrForcelb; | |
double fsrForceN; |
dat = as.matrix(read.table("marks.dat",head=T)); | |
dim(dat); | |
plot(dat); | |
#Step 1: 求出共變異矩陣(covariance matrix) | |
covMat = cov(dat); | |
#Step 2 計算特徴值(eigenvalues)及特徴向量(eigenvectors)。 | |
eig = eigen(covMat); |
//Define Model class | |
var BookModel = Backbone.Model.extend(); | |
BookModel.prototype.sync = function(method,model){ | |
console.log(model.cid); | |
if (method==="create") | |
model.id = 1; | |
}; |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="description" content="Using URL path to determine test case with QUnit framework." /> | |
<link href="http://code.jquery.com/qunit/qunit-git.css" rel="stylesheet" type="text/css" /> | |
<link href="main.css" rel="stylesheet" type="text/css" /> | |
<script src="http://code.jquery.com/qunit/qunit-git.js"></script> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> | |
<script src="http://documentcloud.github.io/underscore/underscore-min.js"></script> | |
<script src="http://documentcloud.github.io/backbone/backbone-min.js"></script> |
在**無瑕的程式碼(Clean Code)**這本書,第一章就說到:
沒有辦法不先讀程式碼就去寫程式,所以讓程式碼更容易閱讀,也會讓程式碼變得更容易撰寫。
可見得寫出令人容易閱讀的程式是一件多麼重要的事,一位專業的程式設計師就是能寫出讓人一目瞭然的程式碼。
What Makes Code Readable: Not What You Think在這篇文章,提到寫出可讀性高的程式碼,有下列幾個標準答案: