本內容不進行任何語言、任何語法、命名法以及寫法(如括號位置)之爭論,亦不爭論任何最佳編輯器(我就喜歡Sublime Text,就這樣)
師大資工 105級
第一屆師大資研社社長
個人開發經驗
合作開發經驗
接手他人code
舊code回顧
a=0
b=14
c=3.141592653589793846
d="y"
e="x"
print("What is:"+a+b+c+d+e+" mean?")
for(a:0..10){
for(ana:a..an[a]){
an[a*ana] = an[a]*ana;
}
}
if False:
# never do
if 1 == 1:
# always do
x = a(1,2,3)
y = b(4,5,6)
z=c(x,y)+d(x,y)
funtion turnGreen(object){
object.color = "yellor"
}
namespace{
enum fruit {a,b};
volatile fruit juice;
extern bool orange(fruit);
run();
}
do{
orange(juice);}while(1);
template <typename S>class
Henry{
int i=0;
S s;
}
為甚麼要 Coding Style?
但最要先考慮的是給誰看
class Checklist{
int numberOfChecklist();
}
a = 3.141592653589793846
pi = 3.141592653589793846
class DataObject{ ... }
name = "data"
file_name = "data"
db_name = "database"
funtion turnGreen(object){
object.color = "yellor"
}
Widget WidgetSet[];
Widget WidgetArray[];
int a=1,b=2,c=3;int getAnswer = a*a*b+a*3;
int a=1,b=2,c=3;
int getAnswer = a*a*b+a*3;
x=getNum(1);print(1)
print(x);print(2);print("GO")
print(3);print("step 1, 2, 3 finish")
//In C++:
if(!good)
printf("bad");
return false;
//In C++:
if(!good)
printf("bad");
return false;
//In C++:
if(!good){
printf("bad");
if(very_bad){
// ...
}
}
return false;
int foo(int attr){
int input;
scanf("%d",&input);
int version = convert(attr);
return version + input;
}
class MyString{
public:
MyString();
~MyString();
int length();
char IndexOf(int index) ;
}
if(a==1){
//...
}
else if(a==2){
//...
}
else if(a==3){
//...
}
switch(a){
case1:
// ...
case2:
// ...
case3:
// ...
}
function fuzz(){
//...
}
function buzz()
{
//...
}
int name_style;
int nameStyle;
int Name_Style;
int name_Style;
int Name_Style;
String str;
length(str);
len(str);
String str;
length(str);
sizeOf(len);
str.length();
str.size();
str.sizeOf();
tab v.s. space
doSomethong(1)
doSomethong(2)
doSomethong(3)
doSomethong(4)
doSomethong(5)
for i in range(1,6):
doSomethong(i)
for i in range(1,6):
# do 1
for i in range(1,6):
# do 2
for i in range(1,6):
# do 1
# do 2
if(true)//...
if(false)//..
if(a OR (!a AND b))
if(a OR b)
if(a){
if(a AND b)//..
}
if( expression ){
return true;
}
else{
return false;
}
return expression;
if(result == true)
if(result)
if(str){
return str.length()==10;
}
else{
return false;
}
return str && ( str.length()==10 );
i += 1 ; // i plus 1
// use loop to calculate the total
int total = 0;
for(int i=0; i < Max; i+=1){
total += items[i];
}
/*************************************
* This is a pretty comment*
* This look so cool ! *
* But hope it never need to fix what*
* this to comment, and I will not need*
* to fix this....*
***************************************/
謝謝大家!m(_ _)m