开始->结束 |停止|结束?

发布于 2024-10-14 06:49:34 字数 354 浏览 4 评论 0原文

我正在编写一个类,我想知道哪对方法对于描述流程周期更有意义:

start() -> stop()
start() -> end()
start() -> finish()

基本上这些方法将在执行任务之前和之后调用。

我问的是英语(特别是在编程中 - 任何语言 -)哪对更常见?

抱歉,我不是母语人士,所以我想听听人们更喜欢哪一个。

如果不够清楚,请让我知道修复它或添加更多信息。

先感谢您。

更新:

这些方法的目的是在运行任务之前和之后调用任何“用户函数”。因为任务本身并没有什么特别的作用。

I'm programming a class and I was wondering which pair of methods makes more sense for describing a process cycle:

start() -> stop()
start() -> end()
start() -> finish()

Basically these methods will be called before and after executing a task.

What I'm asking is in English (specifically in programming - any language -) which pair is more common to see?

Sorry I'm not native speaker so I would like to hear which one people prefer.

If it is not clear enough please let me know to fix it or add more info.

Thank you in advance.

Update:

The intention of the methods is to call for any "user functions" before and after running the task. For the task itself would do nothing special.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

原谅过去的我 2024-10-21 06:49:34

这取决于。

  • 如果调用该方法将中止任务或提前停止任务,请调用 abort()stop()

  • 如果调用该方法将等待任务完成,请调用它waitFor()

  • 如果调用该方法将执行任务的最后步骤,请调用它finish()

  • 如果调用该方法将在任务完成后进行清理,请调用它 Dispose()cleanup()
    大多数语言对这种方法都有一个标准名称;使用它。

  • 更新:如果我正确理解您的情况,我会推荐 OnStarted()OnCompleted()

It depends.

  • If calling the method will abort the task or stop it early, call it abort() or stop().

  • If calling the method will wait until the task finishes, call it waitFor().

  • If calling the method will perform the final steps of the task, call it finish().

  • If calling the method will clean up after the task, call it Dispose() or cleanup().
    Most languages have a standard name for such a method; use it.

  • Update: If I understand your situation correctly, I would recommend OnStarted() and OnCompleted()

-黛色若梦 2024-10-21 06:49:34

这是一个相当上下文的问题,但通常你可以写:

start() ->停止()
开始() -> end()

你可以使用 finish() 来清理和关闭程序,但 close() 更常用。

Thats a fairly contextual question but generally you could write:

start() -> stop()
begin() -> end()

you could use finish() to clean up and close the program but close() is more used.

等待圉鍢 2024-10-21 06:49:34

start() 和 stop() 对我来说最有意义,但前提是 stop() 方法实际上正在停止任务。 (我想到的第一个例子是Java的Thread类,它有start()和stop()方法。)

但是,如果是在执行任务后执行一些操作而不是停止任务本身,那么更好的描述就是该方法是什么实际上,closeResources()cleanup() 等等。

仍然在一定程度上取决于具体情况,但考虑到更新 2,也许像 setup() 和teardown()init() 和completed() 这样的东西会更合适吗?

start() and stop() make most sense to me, but only if the stop() method is actually stopping a task. (First example I think of is Java's Thread class which has start() and stop() methods.)

However, if it's to do some operation after executing the task rather than stopping the task itself, then a better description would be what that method actually does, closeResources(), cleanup() or so on.

Still somewhat dependant on circumstance, but given update 2, peraps something like setup() and teardown(), init() and completed() would be more appropriate?

迷路的信 2024-10-21 06:49:34

高度主观且重要的主题,一些有趣的观点是 此处此处

<代码>开始-> stop ...开始/停止某些活动;有时是向其他组件提供的服务;例如开始/停止监听套接字并处理传入请求

start -> finish ...开始/完成某些任务、处理步骤或类似的;在这里,任务在某种意义上已完成,即它没有中止或取消;例如开始迭代模型优化,完成当前迭代并返回结果

end使用begin比使用start更好(想想 Pascal 语言的构造:-) begin -> endstart -> 可以互换。完成

Highly subjective and important topic, some interesting points are here and here.

start -> stop ... start/stop some activity; sometimes a service provided to other components; e.g. start/stop listening on a socket and processing incoming requests

start -> finish ... start/finish some task, a processing step, or similar; here, the task is completed in some sense i.e. it is not aborted or cancelled; e.g. start iterative model optimization, finish the current iteration and return the result

end goes better with begin than with start (think Pascal language constructs :-) begin -> end is quite interchangeable with start -> finish

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文