Skip to content

Instantly share code, notes, and snippets.

@wingyplus
Last active May 2, 2019 09:29
Show Gist options
  • Save wingyplus/e5c265c6d32b426bf4c868ba9e3ef08d to your computer and use it in GitHub Desktop.
Save wingyplus/e5c265c6d32b426bf4c868ba9e3ef08d to your computer and use it in GitHub Desktop.
async function cacheDo() {
return await cache.do(key, async () => {
return await db.findOne();
});
}
(async () => {
let missyou = await cacheDo();
})()
(async () => {
for let i = 0; i < datasets.length; i++ {
await dowith(datasets[i]);
}
})();
@wingyplus
Copy link
Author

@llun ประมาณนั้นเลยครับ

@ehudthelefthand
Copy link

ผมเข้าใจว่า mislead คือ โค้ดที่อ่านแล้วชวนให้เข้าใจผิด อารมณ์แบบ "คุณนึกว่า มันทำงานแบบนี้ใช่มั้ย จริงๆ แล้วมันทำงานแบบนี้ต่างหาก" ในกรณีของทั้งสองตัวอย่างข้างต้นผมเรียกมันว่า bad code ครับ คือ โปรแกรมมันทำงานอย่างที่โปรแกรมเมอร์อยากให้มันทำนั่นแหละ แต่มันไม่ใช่วิธีที่ดี และสิ่งที่วินพยายามจะสื่อสารคือ อย่าเขียนโค้ดแบบนี้ งี้ปะนะ
ผมติดอยู่อีกนิดเดียวคือ อยากรู้ว่า ต.ย. ที่หนึ่ง ถ้าเขียนให้ดีกว่านี้ จะเขียนยังไงนะครับ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment