【问题标题】:About functions naming, what 'Generic' stand for function name 'helloGCSGeneric'关于函数命名,“Generic”代表函数名称“helloGCSGeneric”
【发布时间】:2020-03-12 06:50:48
【问题描述】:

我的问题是关于“通用”等命名的含义。

我正在看 GCP 的云功能教程, https://cloud.google.com/functions/docs/tutorials/storage#object_finalize

本教程有一个简单的例子。

/**
 * Generic background Cloud Function to be triggered by Cloud Storage.
 *
 * @param {object} event The Cloud Functions event.
 * @param {function} callback The callback function.
 */
exports.helloGCSGeneric = (data, context, callback) => {
  const file = data;

  console.log(`  Event: ${context.eventId}`);
  console.log(`  Event Type: ${context.eventType}`);
  console.log(`  Bucket: ${file.bucket}`);
  console.log(`  File: ${file.name}`);
  console.log(`  Metageneration: ${file.metageneration}`);
  console.log(`  Created: ${file.timeCreated}`);
  console.log(`  Updated: ${file.updated}`);

  callback();
};

即使对我来说,这个函数的作用也很简单。 它是在我理解的对象创建/更新完成时触发的。

“helloGCSFinalization”或“helloGCSGeneration”是有道理的,但为什么它被命名为“Generic”? 在什么情况下使用“通用”?我认为它不同于 C++ 或 Java 等编程语言。

这个问题听起来很傻,但英语不是我的母语,我还是想大致了解一下这个命名上下文。

提前致谢!

【问题讨论】:

    标签: google-cloud-functions google-cloud-storage naming


    【解决方案1】:

    这个非常有趣的问题。我徘徊着还有谁会尝试回答...

    我也不是英语母语人士,但我会尝试以这种方式解决它:由于这是 Google 文档,我尝试使用 Google Translator

    这个通用术语的第一个描述是(至少在我这边:)):

    一类或一组事物的特征或与之相关的;不是 具体的。

    您可能会找到的同义词有:一般、普通、非特定。

    当然我只能猜测,但我认为作者的想法是:“只是简单地触发了谷歌云存储”。虽然我同意computer programming theory中有这样的词。

    这只是我在案件中的声音......

    【讨论】:

    • "您可能会找到的同义词有:一般、普通、非特定。"这似乎是完整的解释,足以让我模糊理解。谢谢你给我线索@vitooh!
    猜你喜欢
    • 2011-04-11
    • 1970-01-01
    • 2018-10-23
    • 2019-09-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-27
    相关资源
    最近更新 更多