Linus Torvalds

หลายครั้งที่เรามักจะได้ยินคำถามว่างานเขียนโค้ดหรืองานเทคนิคจะสามารถทำไปได้จนถึงอายุเท่าไหร่ เพราะพออายุมากขึ้นหรือมีตำแหน่งที่สูงขึ้น คนส่วนใหญ่ก็มักจะไม่ได้ลงมือเขียนโค้ดหรือทำงานเทคนิคเองแล้ว ในงาน Open Source Summit 2020 ทาง Linus Torvalds ได้ให้สัมภาษณ์ว่าทุกวันนี้ตัวเขาเองไม่ได้ทำงานเขียนโค้ดเป็นหลักแล้ว ส่วนใหญ่เน้นอ่านและตอบอีเมลมากกว่า อาจจะมีบ้างที่เขียน pseudo code ตอบกลับไปหรือแนะนำนักพัฒนาว่าโค้ดแบบไหนที่ควรเขียน

ในคอมเมนต์ของข่าวต้นทางก็มีคนมาช่วยอธิบายเพิ่มเติมว่า งานของโปรแกรมเมอร์ในระดับที่สูงขึ้นมักเป็นการตัดสินใจเลือกว่าอะไรควรทำหรือไม่ควรทำ เน้นดูภาพรวมและทิศทางการทำงานเป็นหลักมากกว่าลงมือทำเอง ซึ่งโปรแกรมเมอร์หลายคนอาจไม่ชอบที่ต้องเป็นแบบนี้ แต่ก็ต้องยอมรับในสิ่งที่มันเป็นไป เพราะไม่ใช่ว่าแก่เกินไปที่จะเขียนโค้ด แต่เพราะความอาวุโสของตำแหน่งงานจึงทำให้ใช้เวลากับการเขียนโค้ดได้น้อยลง

นอกจากเรื่องทักษะด้านเทคนิคแล้วทักษะการสื่อสารก็เป็นสิ่งสำคัญ โดย Linus กล่าวว่าการเขียนอธิบายว่าโค้ดนั้นทำงานยังไงก็สำคัญพอๆ กับการเขียนโค้ดให้ดี รวมทั้งหากต้องการที่จะเสนอโค้ดเพื่อเปลี่ยนกระบวนการทำงานของโปรแกรมก็ควรต้องอธิบายให้คนที่รับผิดชอบการตัดสินใจนั้นเข้าใจว่าทำไมถึงต้องเปลี่ยนมาใช้โค้ดใหม่หรือวิธีใหม่ที่เสนอมา เพื่อให้เขาเข้าใจและเชื่อใจในตัวโค้ดนั้น

ที่มา - Slashdot

ภาพของ Linus Torvalds ในงาน Open Source Summit 2018 จาก Linux Foundation

Hiring! บริษัทที่น่าสนใจ

Carmen Software company cover
Carmen Software
Hotel Financial Solutions
Next Innovation (Thailand) Co., Ltd. company cover
Next Innovation (Thailand) Co., Ltd.
We are web design with consulting & engineering services driven the future stronger and flexibility.
KKP Dime company cover
KKP Dime
KKP Dime บริษัทในเครือเกียรตินาคินภัทร
Kiatnakin Phatra Financial Group company cover
Kiatnakin Phatra Financial Group
Financial Service
Fastwork Technologies company cover
Fastwork Technologies
Fastwork.co เว็บไซต์ที่รวบรวม ฟรีแลนซ์ มืออาชีพจากหลากหลายสายงานไว้ในที่เดียวกัน
Thoughtworks Thailand company cover
Thoughtworks Thailand
Thoughtworks เป็นบริษัทที่ปรึกษาด้านเทคโนโยลีระดับโลกที่คว้า Great Place to Work 3 ปีซ้อน
Iron Software company cover
Iron Software
Iron Software is an American company providing a suite of .NET libraries by engineer for engineers.
CLEVERSE company cover
CLEVERSE
Cleverse is a Venture Builder. Our team builds several tech companies.
Nipa Cloud company cover
Nipa Cloud
#1 OpenStack cloud provider in Thailand with our own data center and software platform.
Bangmod Enterprise company cover
Bangmod Enterprise
The leader in Cloud Server and Hosting in Thailand.
CIMB THAI Bank company cover
CIMB THAI Bank
MOVING FORWARD WITH YOU - CIMB is the leading ASEAN Bank
Bangkok Bank company cover
Bangkok Bank
Bangkok Bank is one of Southeast Asia's largest regional banks, a market leader in business banking
MuvMi (Urban Mobility Tech Co.,Ltd.) company cover
MuvMi (Urban Mobility Tech Co.,Ltd.)
Shape the future of urban mobility towards affordable, clean, and safe solutions
T.N. Digital Solution Co., Ltd. company cover
T.N. Digital Solution Co., Ltd.
TNDS has been involving in every first move of banking’s major digital transformation.
KBTG - KASIKORN Business-Technology Group company cover
KBTG - KASIKORN Business-Technology Group
KBTG - "The Technology Company for Digital Business Innovation"
Siam Commercial Bank Public Company Limited company cover
Siam Commercial Bank Public Company Limited
"Let's start a brighter career future together"
Icon Framework co.,Ltd. company cover
Icon Framework co.,Ltd.
Global Standard Platform for Real Estate แพลตฟอร์มสำหรับธุรกิจอสังหาริมทรัพย์ครบวงจร มาตรฐานระดับโลก
REFINITIV company cover
REFINITIV
The Financial and Risk business of Thomson Reuters is now Refinitiv
H LAB company cover
H LAB
Re-engineering healthcare systems through intelligent platforms and system design.
The Gang Technology Co., Ltd. company cover
The Gang Technology Co., Ltd.
We're a Digital Agency that helps our customers transform their business into digital with ease.
LTMH company cover
LTMH
LTMH มุ่งเน้นการพัฒนาผลิตภัณฑ์ที่สามารถช่วยพันธมิตรของเราให้บรรลุเป้าหมาย
Seven Peaks company cover
Seven Peaks
We Drive Digital Transformation
Wisesight (Thailand) Co., Ltd. company cover
Wisesight (Thailand) Co., Ltd.
The Best Choice For Handling Social Media · High Expertise in Social Data · Most Advanced and Secure
MOLOG Tech company cover
MOLOG Tech
We are Modern Logistic Platform, Specialize in WMS, OMS and TMS.
Data Wow Co.,Ltd company cover
Data Wow Co.,Ltd
We enable our clients to realize increased productivity by solving their most complex issues by Data
LINE Company Thailand company cover
LINE Company Thailand
LINE, the world's hottest mobile messaging platform, offers free text and voice messaging + Call
LINE MAN Wongnai company cover
LINE MAN Wongnai
Join our journey to becoming No.1 food platform in Thailand

ครูมักบอก ให้คอมเม้นท์ ทุกบรรทัด
เพราะหากตัองย้อนมาอ่าน อาจจะไม่ได้
ว่ามันคืออะไร ทำไมเขียนไปแบบนี้

เขียนคอมเมนท์เสร็จ แล้วก็มาแก้ แล้วก็ลืมแก้คอมเมนท์

จากนั้นอีกพักใหญ่กลับมาอ่าน อ้าว ตกลงโค๊ดหรือคอมเมนท์กันแน่ที่ถูก

ปล. ถ้านร.ผมเขียนคอมเมนท์ทุกบรรทัด ผมจะตั้งข้อสงสัยก่อนเลยว่า เขียนโค๊ดให้อ่านได้ไม่ได้เหรอ ?

จริงครับ

ส่วนตัวผมว่า ถ้าจะทำ comment ทำแค่ระดับ function ก็พอ
อย่างน้อยรุ้ว่า function นี้มีหน้าที่ทำอะไร input อะไร output อะไร
ที่เหลือ ถ้าแบ่งส่วน code ดีๆ ไม่อัดทุกอย่างใน function เดียวน่าจะอ่านเข้าใจได้ไม่ยาก

ของโครงการ Linux ก็ประมาณที่คุณเขียนครับ Guideline แนะนำให้แบ่ง code ดีๆ แล้วเขียนอธิบายบนหัว function เอา โดยหลีกเลี่ยงการ comment ภายในตัว function

source: Linux Coding Style

Comment ระดับฟังก์ชันก็เพียงพอแล้วครับ แต่ที่ควรทำคือเขียนให้ 1 ฟังก์ชันทำงานแค่อย่างเดียว ซึ่งมันจะทดสอบง่าย ว่าฟังก์ชันทำงานตรงตาม Comment มั้ย?

มีภาษา Assembly ที่จะ comment เกือบทุกบรรทัด (จะได้เข้าใจว่าโค้ดหมายถึงอะไร แต่ก็ยังไม่ได้ทำทุกบรรทัดอยู่ดีครับ)

นั่นคือบาปเลยนะน่ะ ถ้า code ต้อง comment แสดงว่ามี code smell เช่น code ดูอ่านยากเข้าใจยากเกินไป
ควรแตกเป็น function แล้วใช้ชื่อ function บอกว่ากำลังทำอะไรแทน แล้ว comment เมื่อจำเป็น