🔥 "เรื่องอื่นอาจจะประนีประนอมได้ .. แต่เขียนโค้ดสไตล์มั่วซั่ว ประนีประนอมไม่ได้เด็ดขาดดด !"
.
หลายคนน่าจะเคยเจอปัญหากันมาบ้างไม่ว่าจะเป็น
.
🤣 "เมื่อวันก่อนตรูเขียนอะไรลงไปเนี่ยยย !?" จนไปถึง "งงจัด เมื่อเพื่อนร่วมทีมส่งงานมาให้ช่วยดู"
.
ปัญหานี้จะหมดไปถ้าเรารู้ และ เข้าใจสิ่งที่เรียกว่า Coding Style ซึ่งจริง ๆ แล้วในหลาย ๆ ภาษาก็มีให้เราได้อ่านอยู่
.
✅ โดยเจ้าสิ่งนี้จะเป็น "คำแนะนำ" ในการเขียนโค้ดที่ดีของแต่ละภาษา หรือ แต่ละองค์กร ที่ได้มีเกณฑ์ต่าง ๆ กำหนดไว้แล้วนั่นเอง
.
ไม่ว่าจะเป็นเรื่องทั่วไปอย่าง
.
▶️ ควรตั้งชื่อตัวแปรแบบไหน ? ชื่อฟังก์ชันควรเป็นอะไรดี ?
.
▶️ การ Import ของจากข้างนอกมาใช้ อะไรควรทำก่อน หลัง หรือ ไม่ควร ?
.
▶️ จนไปถึง การออกแบบเงื่อนไขการทำงานควรออกแบบอย่างไร ?
.
ซึ่งแน่นอนว่าคำแนะนำที่ดีเหล่านี้จะช่วยให้โปรเจคของเราผ่านไปได้โดยราบลื่นนั่นเอง หากนำมาใช้ในทีมด้วยก็ยิ่งทำให้พวกเราเข้าใจตรงกันได้มากขึ้น
.
"มันเลยเปรียบเสมือนข้อตกลงในการทำงานร่วมกันนั่นเอง <3"
.
แต่จะต้องบอกก่อนนะว่า ไม่ใช่ทุกงานที่เหมาะกับ Coding Style นั้น ๆ หรือ ไม่ใช่ทุกปัญหาจะมีใน Coding Style บอกว่าแก้ไขยังไง หลายครั้งเราอาจจะต้องเพิ่มเติมเอาเอง
.
⚠️ "แต่สิ่งที่เพิ่มเติมจะต้องคุยกันในทีมให้เคลียร์ก่อนเสมอนะ !"
.
ดังนั้นวันนี้เรามาดู Coding Style Guide ของแต่ละภาษาไปพร้อมกันเลยดีกว่า !! (บางภาษาอาจมีตัวน่าสนใจมากกว่า 1 ตัว แอดก็รวมไว้ให้แล้วจ้า)
.
👉 ภาษา Java
.
http://www.oracle.com/technetwork/java/codeconventions-150003.pdf
https://google.github.io/styleguide/javaguide.html
.
👉 ภาษา C
.
http://www.maultech.com/chrislott/resources/cstyle/indhill-annot.pdf
http://www.maultech.com/chrislott/resources/cstyle/Peter_CStyleGuide.pdf
.
👉 ภาษา C++
.
http://www.maultech.com/chrislott/resources/cstyle/Wildfire-C++Style.html
http://www.maultech.com/chrislott/resources/cstyle/CppCodingStandard.html
.
👉 ภาษา Python
.
https://www.python.org/dev/peps/pep-0008/
.
👉 ภาษา C#
https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/index
.
👉 ภาษา JavaScript
.
https://github.com/airbnb/javascript
http://google.github.io/styleguide/javascriptguide.xml
https://www.w3schools.com/js/js_conventions.asp
.
👉 ภาษา Dart
https://dart.dev/guides/language/effective-dart/style
.
👉 ภาษา PHP
http://www.php-fig.org/psr/psr-1/
http://pear.php.net/manual/en/standards.php
.
👉 ภาษา Objective-C
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CodingGuidelines/CodingGuidelines.html
.
👉 ภาษา Kotlin
https://kotlinlang.org/docs/reference/coding-conventions.html
.
👉 ภาษา Swift
https://github.com/raywenderlich/swift-style-guide
.
👉 ภาษา Visual Basic.NET
https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/index
.
👉 ภาษา Ruby
https://github.com/bbatsov/ruby-style-guide
https://github.com/airbnb/ruby
.
👉 ภาษา R
http://web.stanford.edu/class/cs109l/unrestricted/resources/google-style.html
.
👉 ภาษา Go
https://golang.org/doc/effective_go.html
.
"เรียบร้อย ครบจบทุก Guideline ใครที่อยากทำงานกับทีมง่าย ๆ แนะนำให้ลองใช้กันดูได้เลยจ้า" <3 <3 <3
.
#borntoDev - 🦖 สร้างการเรียนรู้ที่ดีสำหรับสายไอทีในทุกวัน
「google javascript style guide」的推薦目錄:
- 關於google javascript style guide 在 BorntoDev Facebook 的精選貼文
- 關於google javascript style guide 在 卡斯伯 Facebook 的最讚貼文
- 關於google javascript style guide 在 Google JavaScript Style Guide - Google · GitHub 的評價
- 關於google javascript style guide 在 Style guides for Google-originated open-source projects 的評價
- 關於google javascript style guide 在 5 JavaScript Style Guides — Including AirBnB, GitHub, & Google 的評價
- 關於google javascript style guide 在 ProgTer club - Google JavaScript Style Guide | Facebook 的評價
- 關於google javascript style guide 在 JS Javascript style guide 各位選擇哪一種? - 前端工程師 - Dcard 的評價
- 關於google javascript style guide 在 JavaScript Style Guides: What are they and which one to use? 的評價
- 關於google javascript style guide 在 Google JavaScript Style Guide - Pinterest 的評價
- 關於google javascript style guide 在 Google JavaScript Style Guide - GitHub Wiki SEE 的評價
- 關於google javascript style guide 在 [情報] google javascript style guide - 看板Ajax | PTT數位生活區 的評價
- 關於google javascript style guide 在 Is there a recommended HTML/CSS/JavaScript coding style ... 的評價
google javascript style guide 在 卡斯伯 Facebook 的最讚貼文
現在主要的 Style guide 有 StandardJS, Airbnb, Google 三家
我自己雖然偏好 Standard 但現在也轉向其它兩家 (懶得加分號啊~)
這裡列出 Google Style Guide 的一些特色
- 使用兩個空白 (別用四個空白或 tab)。
- 請記得加入分號。
- 先別用 ES6 module export,因為語意尚未完全定義。
- 別使用 var,改使用 let, const。
- 盡可能使用 arrow function。
- 使用 template String,並且大括號內部變數不需要額外空白如: `${variable}`。
- const 所宣告的變數使用全大寫。
- 字串使用單引號。
介紹: https://goo.gl/5RufGG
Google JavaScript Style Guide:
https://google.github.io/styleguide/jsguide.html
google javascript style guide 在 Style guides for Google-originated open-source projects 的推薦與評價
Google Style Guides ... Every major open-source project has its own style guide: a set of conventions (sometimes arbitrary) about how to write code for that ... ... <看更多>
google javascript style guide 在 5 JavaScript Style Guides — Including AirBnB, GitHub, & Google 的推薦與評價
Whether you're just starting to learn JavaScript, or getting ready for your big interview with AirBnB, here are 5 style guides that can help ... ... <看更多>
google javascript style guide 在 Google JavaScript Style Guide - Google · GitHub 的推薦與評價
File names must be all lowercase and may include underscores ( _ ) or dashes ( - ), but no additional punctuation. Follow the convention that your project uses. ... <看更多>
相關內容