Last active
May 2, 2019 09:29
-
-
Save wingyplus/e5c265c6d32b426bf4c868ba9e3ef08d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function cacheDo() { | |
return await cache.do(key, async () => { | |
return await db.findOne(); | |
}); | |
} | |
(async () => { | |
let missyou = await cacheDo(); | |
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(async () => { | |
for let i = 0; i < datasets.length; i++ { | |
await dowith(datasets[i]); | |
} | |
})(); |
ผมเข้าใจว่า mislead คือ โค้ดที่อ่านแล้วชวนให้เข้าใจผิด อารมณ์แบบ "คุณนึกว่า มันทำงานแบบนี้ใช่มั้ย จริงๆ แล้วมันทำงานแบบนี้ต่างหาก" ในกรณีของทั้งสองตัวอย่างข้างต้นผมเรียกมันว่า bad code ครับ คือ โปรแกรมมันทำงานอย่างที่โปรแกรมเมอร์อยากให้มันทำนั่นแหละ แต่มันไม่ใช่วิธีที่ดี และสิ่งที่วินพยายามจะสื่อสารคือ อย่าเขียนโค้ดแบบนี้ งี้ปะนะ
ผมติดอยู่อีกนิดเดียวคือ อยากรู้ว่า ต.ย. ที่หนึ่ง ถ้าเขียนให้ดีกว่านี้ จะเขียนยังไงนะครับ
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@llun ประมาณนั้นเลยครับ