编程语言/命名/of还是for

来自康健生活
Kangkk​(留言 | 贡献)2020年6月14日 (日) 16:45的版本
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

引言

遇到一个命名上很纠结的问题,假如我有一个表 User,现在想向表 User 中添加模拟数据,创建函数过程中应该如何为这个添加模拟数据的逻辑函数命名呢?

有两种选择,哪个合适:

  • create of user :“创建用户”。
    eq: This would mean you have to manually create a number of user subscriptions,
    eq: It may take a few seconds to create all of the new user's files.
  • create for user :“为用户创建”。
    eq: Would you like to create UI for the user to interact with your add-in?
    eq: Create a directory for the user and give him the necessary permissions.

of 和 for 都是介词,后面都是 + 名词/相当于名词的词 以此构成介词短语。

在作定语时:

  • of 表示所属关系。
    eq: a student of our class
  • for 表示目的用途。
    eq: a book for children

内置函数

在很多内置函数中,如 indexOf、lastIndexOf(javascript)、等,使用的都是 Of 连接词。