Skip to content
GitLab
    • Explore Projects Groups Topics Snippets
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • N naming-conventions
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Jira
    • Jira
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Kamolpop Kuadsantia (ไอซ์)
  • naming-conventions
  • Wiki
  • Home
Last edited by Kamolpop Kuadsantia 9 years ago
Page history
This is an old version of this page. You can view the most recent version or browse the history.

Home

Naming conventions

File name

File name {filename}

1. Use alpha and numeric characters only

ใช้ตัวอักษร (A to Z, a to z) และตัวเลข (0 to 9) เท่านั้น การจำกัดเพาะตัวอักษรและตัวเลข จะทำให้ชื่อไฟล์ง่ายต่อการอ่านและจำ

2. File names should be unique

ชื่อไฟล์ที่เหมือนกัน อาจนำไปสู่การลบไฟล์โดยไม่ได้ตั้งใจ

3. File names should be clear and concise

ชื่อไฟล์ควรให้ข้อมูลเพียงพอที่จะอธิบายเนื้อหาในไฟล์ได้อย่างชัดเจน ใช้ชื่อไฟล์ที่สั้น แต่ยังต้องให้มีความหมายชัดเจน หากต้องการใช้คำย่อควรใช้ “คำย่อมาตรฐาน” เช่น
“Rcvd” แทน “received” “Attch” แทน “attachment”.

4. Demarcate words with Capital Letters

การแยกคำด้วย capital letters แทนการใช้ underscores, hyphens จะทำให้หลีกเลี่ยงการใช้ชื่อไฟล์ที่ยาวเกินความจำเป็น

5. Avoid repetition and redundancy

ชื่อไฟล์ที่ซ้ำซ้อน ทำให้ชื่อไฟล์ยาวเกินความจำเป็น ไม่ควรใช้ “a”, “and’, “of”, “the”, “to” หากไม่จำเป็น ชื่อไฟล์ไม่จำเป็นต้องบอกประเภทของไฟล์ เช่น “Pdf”, “Presentation”, “Spreadsheet”. ชื่อไฟล์ไม่จำเป็นต้องมี ชื่อผู้สร้าง หรือวันที่สร้าง เช่น “NamingConventions” แทน “Pdf_records_management_guidance_on_ naming_conventions_for_electronic_documents 6_June_2007_E_Longate”

6. Gives dates back to front

ยึดตามมาตรฐาน ISO 8601:2004

YYYY Year

YYYYMM Year and month

YYYYMMDD Year, month and day

hhmmss Hours, minutes and seconds

เช่น “200708Invoices” แทน “August2007Invoices”

7. Use two-digit numbers (unless a date or a number with more than two digits)

การใช้ตัวเลขสองหลัก (ในกรณีใช้เลขไม่เกิน 99) จะทำให้ไฟล์มีการเรียงลำดับที่ถูกต้องแลพเป็นไปในทางเดียวกัน เช่น “NamingConventionsV01” แทน “NamingConventionsV1”

8. Avoid using non-alphanumeric characters

หลีกเลี่ยงการใช้อัครพิเศษ เช่น * : \ / < > | " ? [ ] ; = + & £ $ , .

Class name

ชื่อ Class ต้องเป็นคำนาม ที่ครอบคลุมการทำงานของ Class เช่นถ้าเราจะสร้าง Class ของนกฮัมมิ่งเบิร์ดควรจะตั้งชื่อคลาสเป็นคำว่า

  class HummingBird extends Bird

เมื่อเขียนชื่อ Class และเรียก function ต้องอ่านแล้วเข้าใจ เช่น

  $HummingBird->fly();

Function name

Pick One Word per Concept ไม่ใช้คำหลายๆคำที่มีความหมายเดียวกันเช่นฟังก์ชั่นที่ใช้ดึงค่า ควรมีการตกลงกันว่าเป็นคำใดคำหนึ่งเช่น

  function getWingsColor() {
    ...
  }

  function getLegsColor() {
    ...
  }

  function getFeatherColor() {
    ...
  }

Function ที่ return boolean ให้ขึ้นต้นด้วย is, has เช่น

  $HummingBird->isBird();
  $HummingBird->hasWings();

Function ที่ return ค่า attribute ใน Class ให้ใช้ get นำหน้า เช่น

  $HummingBird->getColor();

Function ที่ set ค่าให้ attribute ใน Class ให้ใช้ set นำหน้า เช่น

  $HummingBird->setEyeColor();

Variable name

ตัวแปร type boolean ต้องมี is หรือ has นำหน้า เช่น

  $isActived = true;

ชื่อตัวแปรที่ไม่ใช่ boolean ต้องใช้คำนามที่ตรงกับหน้าที่ของตัวมันเอง เช่น

  $eyeColor = “red”;

ห้ามใช้ตัวแปร flag เช่น

  $flag = true;

ตัวแปรที่เป็นค่าคงที่ต้องเป็น UPPERCASE เช่น

  PI = 3.14;

ตัวแปรที่เอามาใช้วน Loop ต้องเป็น พหูพจน์ value ของแต่ละรอบต้องเป็น เอกพจน์ เช่น

foreach ($birds as $bird) {
    ...
}

Reference

Naming conventions for electronic document

Clone repository
  • Home

Menu

Explore Projects Groups Topics Snippets