【问题标题】:How to name a function that creates fixpoint results on its input?如何命名在其输入上创建定点结果的函数?
【发布时间】:2014-07-03 11:23:33
【问题描述】:

我有一个装饰字符串的函数。如果修饰的字符串再次被提供给函数,则保证不会更改。这种函数的标准命名约定如何?我可能会创建一个命名空间,因为我需要其中一些功能。

我想出了:

repetition_safe.decorate(me);
fixpoint_gen.decorate(me);
one_time_effect.decorate(me);

但我真的不喜欢这些。

你会如何命名命名空间或函数?

【问题讨论】:

    标签: api naming-conventions decorator naming api-design


    【解决方案1】:

    怎么样:

    StringDecorator.MakeImmutable(input);
    

    我认为“MakeImmutable”比“Decorate”更好,因为后者是模棱两可的,即阅读代码的用户不会知道“decorate”做了什么,而“makeImmutable”会通知用户这个函数将进行输入字符串不可变/不可更改。

    【讨论】:

      猜你喜欢
      • 2023-04-01
      • 1970-01-01
      • 2019-03-26
      • 2015-10-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-12
      相关资源
      最近更新 更多