กลุ่มที่ 1 {}
function hello() {
...
}
หรือ
function hello()
{
...
}
กลุ่มที่ 2 for
for(i=0;i<10;i++)
for(i = 0; i < 10; i++)
for ( i = 0; i < 10; i++)
ส่วน if, while เอาทั้งสองมารวมๆ กัน ไม่ทราบว่าเพื่อนๆ เขียนแบบไหนกันเหรอครับ
ผมเขียนแบบ ที่ 1 กับ 3 ไม่ทราบว่า คนอื่นๆ เขียนกันแบบไหนครับ
ตอนนี้เริ่มไป python กำลังเซ็ง space กับ tab อ่ะครับ มึนตึ๊บ แต่ภาษามันสวยดี
ผมเขียนงี
wklk Mon, 30/06/2008 - 19:24
ผมเขียนงี้ครับ function hello(){ ... }
for(i=0; i<10; i++)
function hello() { …
Nohohon Mon, 30/06/2008 - 18:32
function hello() { ... }
for(i=0; i<10; i++)
function hello() {
kaze Mon, 30/06/2008 - 20:09
function hello() { ... }
for (i = 0; i < 10; i++)
หลัง keyword มี 1 space แต่ถ้าเป็น function วงเล็บติดเลยอ่ะครับ ผมไว้ใช้ regular expression เพื่อหาว่า function อะไรถูก call กี่ครั้งบ้่างอ่ะครับ ^^
function
Silence Mon, 30/06/2008 - 20:23
function hello()
{
...
}
for( i = 0; i < 10; i++ )
--
Without Wax - T.J.M. Potter
function hello() {
iake Mon, 30/06/2008 - 20:33
function hello() { ... }
for (i = 0; i < 10; i++)
int main(int argc, char
sugree Tue, 01/07/2008 - 01:13
tab = 8 เสมอ ชื่อจริง K&R ชื่อเล่น Linux Kernel Coding Standard
ยังมีแบบอื่นอีก http://en.wikipedia.org/wiki/Indent_style
ผมตั้ง tab=4
mk Tue, 01/07/2008 - 01:15
In reply to int main(int argc, char by sugree
ผมตั้ง tab=4 ถ้าเป็น html ใช้ tab=2
เปิดกระทู้ .vimrc ดีกว่า
เหมือนกัน
kaze Tue, 01/07/2008 - 01:33
In reply to ผมตั้ง tab=4 by mk
เหมือนกัน make up language ใช้ tab 2 ที่เหลือเป็น 4
เอา .vimrc
moniguna Wed, 02/07/2008 - 08:11
In reply to ผมตั้ง tab=4 by mk
เอา .vimrc มาโชว์กันเลย :p
4 space / tab ครับ
Ford AntiTrust Tue, 01/07/2008 - 01:34
In reply to int main(int argc, char by sugree
4 space / tab ครับ ทุกภาษาที่ผมใช้จะแบบนี้หมดเลย
Ford AntiTrust’s Blog | PHP Hoffman Framework
int main(int argc, char
noyzilla Wed, 02/07/2008 - 08:09
In reply to 4 space / tab ครับ by Ford AntiTrust
อยากให้ vi พิมพ์ภาษาไทยได้จัง
Noyzi!!a's Blog
ผมใช้ MacVim
moniguna Wed, 02/07/2008 - 10:57
In reply to int main(int argc, char by noyzilla
ผมใช้ MacVim ก็พิมพ์ภาษาไทยได้นะครับ แต่เว้นวรรคไม่สวยแค่นั้นเอง :p
โดยรวมแล้
moniguna Wed, 02/07/2008 - 08:15
In reply to 4 space / tab ครับ by Ford AntiTrust
โดยรวมแล้วเขียนเหมือนผมเลย 4space/tab เหมือนกันด้วย แต่ตรง for ผมจะเขียนแบบนี้
for(i = 0; i < 10; i ++){
}
ปกติแล้ว Operator ผมจะเว้นวรรคหน้าหลัง
กรำ
Ford AntiTrust Wed, 02/07/2008 - 11:01
In reply to โดยรวมแล้ by moniguna
กรำ ผมลืมเว้นส่วนนี้ ตอน copy จากคุณ sugree -_-' ;P (จะสังเกตว่าตัวอื่น ๆ ก็เว้น ท่าทางจะตาลาย)
Ford AntiTrust’s Blog | PHP Hoffman Framework
แทบจะเหมื
ipats Wed, 02/07/2008 - 02:04
In reply to int main(int argc, char by sugree
แทบจะเหมือนกันเลยครับ ต่างกันนิดเดียวแค่ บล็อก { } ของฟังก์ชัน ผมเอา { ขึ้นไป เหมือนบล็อกของ for กับ if ส่วนแท็บ ปกติผมใช้แค่ 4 (เยอะเกินมันล้นอ่ะ)
---------- iPAtS
ทำเป็นโพล
ABZee Tue, 01/07/2008 - 06:25
ทำเป็นโพลเลยได้ไหมเนี่ย อยากรู้เหมือนกัน
PoomK
จริงๆ
sugree Tue, 01/07/2008 - 06:35
จริงๆ แล้วผมไม่ค่อยใส่ใจว่าเขียนยังไงนะ ถ้าเป็นโค้ดคนอื่นผมปรับตัวให้เขียนแบบอื่นได้__ตราบใดที่มี indent__
ถ้าไม่มี indent ก็ลาขาด
function hello()
HyBRiD Wed, 02/07/2008 - 01:48
function hello() {
…
}
for(i=0;i<10;i++)
NERD GOD
function hello() { } for
lancaster Wed, 02/07/2008 - 10:19
function hello() {
}
for (i = 0; i < 10; i++) ...
ชอบแบบนี้อะ
กระทู้นี้
Ford AntiTrust Wed, 02/07/2008 - 11:07
กระทู้นี้น่าจะเป็นตัวอย่างที่ดีกับคนที่เขียนโปรแกรมรุ่นใหม่ ๆ นะ ว่าจะใช้ style code แบบไหน แล้วถ้าเขียนเป็นทีมก็ควรกำหนด style ซะแต่เริ่มต้นไปเลย จะได้เป็นทิศทางเดียวกัน
อย่างผมจะมีคู่มือ style ผมไว้เลย เวลาโยน code ให้คนอื่นเขียนต่อก็เอา style docs ผมไปด้วย เวลาแก้ไข จะได้ไม่ต้องมานั่งจัด style ใหม่ โดยเฉพาะเรื่อง tab กับ space นี่สำคัญมาก ๆ ยิ่ง Python นี่ต้องใส่ใจเลย ไม่งั้นโปรแกรมหลุดแถม bug ตรึมแน่ ๆ
ส่วน tab ตอนแรก ๆ ที่เขียน code นี่ใช้ 8 space นะ แต่ไป ๆ มา ๆ รู้สึกว่ามันเยอะเกินเลยปรับเหลือ 4 space ส่วน 2 space นี่ไม่ไหว บางครั้งมันหาความแตกต่างยากไปหน่อยนึง เลยเอา 4 ดีกว่า แล้วก็ใช้ Editor ที่ทำ Folding Brace กับ Matching Brace ได้ด้วยเพราะช่วยได้เยอะ เวลาหา scope ของการทำงาน ไม่ต้องมานั่งเพ่ง ๆ หรือ scroll ขึ้น-ลง (ใน EditPlus รุ่นใหม่ ๆ มีความสามารถนี้อยู่แล้ว) เลยทำให้ทำงานได้เร็วขึ้นลดปัญหาไปได้เยอะครับ
Ford AntiTrust’s Blog | PHP Hoffman Framework
นี่เลย function
few Wed, 02/07/2008 - 11:14
นี่เลย
function hello() { .. }
กับ
for(i=0; i<10; i++)
my ifew
function hello() {
pococyber Wed, 02/07/2008 - 11:16
function hello()
{
…
}
อิอิ ชอบเขียนแบบมี Indent ครับ ^^
ทำตาม code
rocketbomb Wed, 02/07/2008 - 12:11
ทำตาม code conventions ของ c กับ java ครับ
ตามมาตรฐา
sugree Wed, 02/07/2008 - 16:03
In reply to ทำตาม code by rocketbomb
ตามมาตรฐานไหนครับ อยากยลโฉม
Code Conventions for the
anu Wed, 02/07/2008 - 18:56
In reply to ตามมาตรฐา by sugree
<A href="http://java.sun.com/docs/codeconv/html/CodeConventions.doc6.html#449">Code Conventions for the JavaTM Programming Language
พึ่งรู้ว่
lancaster Sun, 06/07/2008 - 23:16
In reply to Code Conventions for the by anu
พึ่งรู้ว่าตัวเองเขียนตาม code convention ของ java
4 space เสมอ
IceDagger Thu, 03/07/2008 - 01:41
4 space เสมอ ไมใช้ tab
int main(int argc, char** argv){int a = 0;int b = 0;if (a == 0){....}for (int i=0; i < 10; ++i){}}int main(){ } for (i=0;
pawinpawin Fri, 04/07/2008 - 23:28
int main(){
}
for (i=0; i<10; i++)
เอ แต่ผมเขียนโปรแกรมไม่เป็นนี่นา
อิอิ ชแว้ปป
function test(){ print
willwill Sun, 06/07/2008 - 22:09
function test(){ print 'a'; }(จริงๆ ใช้ tab ครับ แต่โดนมันตัด)ส่วน for ไม่ได้ใช้ครับ (ใน PHP ใช้ foreach กับ while แบบ
foreach($var as $i => $n){ do(); } $i=0; while($i <= 10){ print $i; }ใน python ใช้ for i in var ตลอดครับ)ใครเป็น
sugree Mon, 07/07/2008 - 10:53
ใครเป็น Hungarian บ้าง
เฮอะๆ
tekkasit Mon, 07/07/2008 - 12:15
เฮอะๆ อ่านแล้วผมนึกถึงนี่เลยครับ
How to Write Unmaintainable Code
ตอนนี้มันแยกเป็นส่วนๆแล้ว ไม่ได้เรียงในแผ่นเดียว
ลองอ่านที่นี่ก็ได้ครับ ยังเป็นรุ่นแผ่นเดียวอยู่
DevX: How to Write Unmaintainable Code
All man style ครับ
crucifier Mon, 07/07/2008 - 12:21
All man style ครับ