Giter VIP home page Giter VIP logo

english-for-programmers's Introduction

《程式英文》 English for Programmers

「英文」是不少人學程式的關卡,而「命名」是電腦科學最難的問題之一。

這裡搜集了常見的「如何用英文命名、表達程式裡某個東西?」的問題與答案,幫助你學會 用英文提昇程式可讀性 🔎 。

歡迎提出 問題 ❓ / 建議 💡 / 感想 💭

《程式英文》 GitHub 討論區 💬 https://bit.ly/321ResR

2020-11-27 cognitive load

2020-11-16 JSON

2020-11-07 LeetCode, naming, stack, digit, place, upper bound, majorant, lower bound, minorant, inclusive, exclusive

2020-10-02 naming

2020-09-25 slice, split, detach, disconnect, delimiter, separator, divider, splitter, break

2020-09-18 attribute, property

2020-09-11 size, return, result

2020-09-04 state, status, ordinal

2020-08-28 copy, clone, duplicate

2020-08-21 validate, verify, argument, parameter

2020-08-14 check, test, verify, validate, assert, ensure, confirm, authenticate, scan, ping, analyze, audit, diagnose, inspect

2020-08-07 times, calculate, compute, sum, total

2020-07-31 clear, empty, delete, remove, clean, erase, cancel, dismiss

2020-07-24 type, kind, category, class, classification, sort, group, tag, attribute, property

2020-07-17 ASCII, Unicode

2020-07-10 count, number, quantity

english-for-programmers's People

Contributors

twy30 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

english-for-programmers's Issues

如何命名「遞迴(recursion)方法」?

例如說

int GetShortestDistance( input )
{
    ... // 整理 input 及其它準備工作

    var ret = _實作某最短距離遞迴演算演法_( ... );

    ...
}

要如何為那 _實作某最短距離遞迴演算演法_() 方法取名字?


幾個可能性:

  • 加底線: _GetShortestDistance()
  • Recursively: GetShortestDistanceRecursively()
  • Impl: GetShortestDistanceImpl()
  • 在另一工具類別(utility class)裡實作同名方法 GetShortestDistance()

介詞: with, at, from, to, in, than, ... 使用情景

台式英文、漢語拼音、日文拼音的優缺點?

https://www.ptt.cc/bbs/Soft_Job/M.1594363672.A.7D0.html

推 vi000246: 我喜歡台式英文 bulletWeight remainLife

推 goldflower: 看過中國人用拼音寫扣 jin_jia_ki_si

推 gasbomb: 上一份工作看到的 氣死https://i.imgur.com/x9GmljV.jpg

→ OrzOGC: 用拼音真的...還有日文拼音的...冏...

完全能理解,解決問題優先。

語言能做到優雅當然是好,但最重要的功能還是溝通(人與人的溝通、人與機器的溝通)。

如何命名「次數」變數?

原題出處:

https://www.facebook.com/twy30/posts/2597608983822750?comment_id=2597770413806607

如果遇到「次數」這個詞,可以用「times」命名嗎??


很有趣的問題 🤔

我覺得 "times" 是個能接受的選擇。

如果能知道上下文情景,或許有其它字可以選,例如:

  • occurrenceCount 發生次數
  • repetitionCount 重覆次數
  • hitCount 「命中 🎯」次數 ← 可以是字面上、物理上的「命中」,也可以是抽象上的,例如,「搜尋引擎關鍵字」的「命中」次數。

last vs. past

讀者提問: "last week" 與 "past week" 有什麼不同?

我一下能想到的:

  • "last week" 比較接近「上週」
    • 假設一週是從日曆上的週日開始、週六結束
    • 今天是 2020-08-11 週二
    • 「上週」是指「2020-08-02 週日 到 2020-08-08 週六」
  • "past week" 比較接近「過去七天」
    • 今天是 2020-08-11 週二
      • 如果是 2020-08-11 週二 早上說「過去七天」,指的多半是「2020-08-04 到 2020-08-10」
      • 如果是 2020-08-11 週二 晚上說「過去七天」,指的多半是「2020-08-05 到 2020-08-11」

補充「檢查」 情境+命名 範例

https://www.facebook.com/twy30/posts/2615081322075516?comment_id=2615083622075286

如果每個命名可以附上一個情境+命名的範例,就更清楚能看出微妙的差異點

https://www.facebook.com/twy30/posts/2615081322075516?comment_id=2615083622075286&reply_comment_id=2615104028739912

我可以提供幾個例子當疑問,然後你可以給建議或是看法,選擇哪一個比較合適,或許可以這樣試試。
例如:我要檢查某個 Product 的 instance 毛利率有沒有 > 6%.
例如我要驗證 user 的 IP 是不是合法的。
例如我要確認這是不是加購的商品。
例如我要確保訂單金額不可以< 0。

中文的用詞是我刻意隨便用,而且故意用不一樣的。

變數名稱與上下文脈絡(method/function, class, namespace)的關係

https://www.facebook.com/photo.php?fbid=2586040414979607&set=a.2586039114979737&type=3&comment_id=2586217628295219

我覺得在大多數的情況下
count 與 quantity 就好了
原因是因為
既然是變數
則其上層勢必還有方法 類別 甚至 namespace
一般來說 在 SRP之下
方法中有滿高機率
是不需要額外宣告變數的
即使要宣告 通常也是屬於該方法所定義的類別名稱相關
或是方法名稱相關
要用到兩種count 的方法機率極低
此時再追加名稱即可
或是 可能已經違反SRP的情境
仔細想一下 是否真的很長在同一個方法中使用兩種count
至少已我SRP的這幾年中幾乎沒發生過


十分同意,架構規劃得好的話,程式碼上下文脈絡(方法/類別/namespace)可以消除語意模糊(ambiguity)之處。

當下: now, current, present 有什麼不一樣?

自己的認知只到: now 是副詞,而 present 和 current 都可以當形容詞。

查資料的時候,發現 stackoverflow 有人曾經提過這樣的問題:

When should DateTime.now.utc vs. Time.current.utc be used in Rails?

https://stackoverflow.com/questions/12748626/when-should-datetime-now-utc-vs-time-current-utc-be-used-in-rails

或許就後端而言,now 與 current 之間有微妙的重疊?

雖然也有 Google 到一些用法像是 current selling price of something、current exchange rate,但不知道為何不能用 present ?

我想知道更多關於 now, current, present 的區別,先感謝大大(們)。

第N個要怎麼命名

你好,我最近在處理股票資料的api,
有一個內容是我想要將資料整理成K線的形式,
我的Kbar calss中想要存「屬於今天中的第N根Kbar」,這種狀況要怎麼命名呢。

像是以一根10:00~ 10:15的15分鐘k線,8:45開盤,這個變數會存5,代表是今天的第六根K線

如何表達資料從哪邊來,又要給誰

如果想表達資料從哪邊取得該怎樣命名英文表較合適呢?

舉例:API回應
我會寫ApiResponse{From/IN/By/For}資料,
但也有人會寫Get資料,
但在程式維護上會不知道這資料從哪邊來的,變成要去追蹤程式。

如果要給別人
To、Send、Set

現在簡單式(simple present)的使用情景

鄉民提供的題目

https://www.ptt.cc/bbs/Soft_Job/M.1599191750.A.773.html

→ CoNsTaR: 也可以講一下 has, with, is, at... 也可以命名狀態變數 09/05 04:46


想到了幾個例子:

validate vs verify

不知道能不能用 validation vs verification 來學差異?

可以的話

According to the IEEE Standard Glossary of Software Engineering Terminology, verification is defines as "The process of evaluating a system or component to determine whether the products of a given development phase satisfy the conditions imposed at the start of that phase." Validation, on the other hand, is defined as "The process of evaluating a system or component during or at the end of the development process to determine whether it satisfies specified requirements."

https://users.ece.cmu.edu/~koopman/des_s99/verification/

「種類(type, kind, sort, class, category, classification)」該用哪個字?

type, kind, sort, class, category, classification

在各領域又有特殊的單字,例如:

  • 車: model, make, 及你提到的 classification
  • 電影: genre
  • 動物: breed

https://www.facebook.com/media/set/?set=a.2586039114979737&type=3&comment_id=2586318228285159

種類用的class還是category這個單字好呢?


https://www.facebook.com/media/set/?set=a.2586039114979737&type=3&comment_id=2586400861610229

除了數量,種類也很常遇到。例如 車種,大大會建議用 "categoryOfCars"、"typeOfCars" 或是 "carClassification" (參考維基百科標題)

ref: https://en.wikipedia.org/wiki/Car_classification

變體: Variant vs Variation

在電商裡面,有些商品會在細分成具有不同的子屬性,例如: iPhone X 可以有

  • 黑 iPhone X
  • 白 iPhone X
  • 紅 iPhone X

不同顏色的 iPhone X 對 iPhone X 來說就是屬於它的變體, 在命名上, 不太確定用哪一個單字好

期間: period vs. duration

如題,單純好奇 😅 <--某日靈光一閃,發現自己分不出來
謝謝 orz

同時我也在網路上發現有趣的題目:
https://forum.wordreference.com/threads/diffrences-between-period-and-duration.1703198/

image

網友解說:(英文力不足看懂 orz)

image
image


劍橋字典:

period

https://dictionary.cambridge.org/zht/%E8%A9%9E%E5%85%B8/%E8%8B%B1%E8%AA%9E-%E6%BC%A2%E8%AA%9E-%E7%B9%81%E9%AB%94/period

a length of time 一段時間,時期
in school, a division of time in the day when a subject is taught 課時,學時,一節(課
a fixed time during the life of a person or in history 人一生中或歷史上的)時期;階段

duration

https://dictionary.cambridge.org/zht/%E8%A9%9E%E5%85%B8/%E8%8B%B1%E8%AA%9E-%E6%BC%A2%E8%AA%9E-%E7%B9%81%E9%AB%94/duration

the length of time that something lasts 持續時間

組合字 / compound nouns / stacked modifiers and nouns 要怎麼用?

如何命名「集合名詞(collective noun)數量變數」?

例如說,

population (人口) 算是哪種?

  • 💧 不可數名詞
  • 🐈 可數生物
  • 📦 可數非生物

似乎 count / number / quantity 都可以用在 population 上?


其它像是

  • army
  • team

似乎會用 size 這個字?


或許集合名詞 👨‍👩‍👧‍👦 有它自己的規則?

  • ammo / ammunition

Related: #2

「翻譯」如何做到信達雅?

https://www.facebook.com/media/set/?set=a.2586039114979737&type=3&comment_id=2586400861610229

延伸的問題是,像是我這種英文不好的人 😅,遇到不會的 中翻英 狀況,通常以 google / wiki 解決,但 (貌似 😆) 有三種可行方案,要怎麼選比較好?多找幾個網頁嗎?

我也不知道有沒有更好的方法 😅

有些語意、語境上的東西,是字面、書面資料比較難達傳、查詢的。而針對程式設計中的英文語意資料似乎更是稀少。

我希望我現在在做的整理工作能幫上你的忙;你愈是提問題,對我的幫助就愈大,我整理出來的資料就愈完整 👍

能不能用books代表書本數量?

https://www.facebook.com/media/set/?set=a.2586039114979737&type=3&comment_id=2586318228285159

請問能不能用books代表書本數量呢??

我會從 語意 及 實務 兩個角度來看:


語意

"numberOfBooks" 或 "bookQuantity" 會比 "books" 更接近『書本數量』,也更不需要依賴上下文來解讀。
因為 "books" 在語意上來說比較接近「書的集合(collection)」;例如,一個「書的物件」的陣列(array),就適合以 "books" 來命名。
所以,如果是我,我會選「不使用 books 來代表書本數量,而是用 numberOfBooks 或 bookQuantity 」。


實務

語言是溝通工具,是人(程式設計師)與機器的溝通工具,也是人(一開始的開發者)與人(後來的維護者)的溝通工具。
如果身處的環境、團隊文化已經有既存的語言習慣 (方言) ,我會使用團隊習慣的方言,優先確保團隊運行順利。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.