Artem Tikhomirov
Artem Tikhomirov

Reputation: 21676

Best way to name async method

Where is an API of, let’s say, one method: “DoSomething()”. There should be two versions of the method: asynchronous and synchronous. We should encourage API users to use async one so sync one probably should get more complicated and explicit name. So the problem is: how should we name this pair. To the date we’ve came up with:

None of above schemes seems like optimal for us. Any suggestion folks?

Update. BTW do not hesitate to post one of the above as an answer if it fit you.

Upvotes: 9

Views: 4149

Answers (3)

Clement Herreman
Clement Herreman

Reputation: 10536

If you want to encourage your user to use async ones over sync, then I'd go for this one : DoSomethingSync() / DoSomething()

However, tell your users loud and clear that all methods are async if not told otherwise.

Example : node.js uses this notation : fschmodSync and fschmod

But the most important is to stick with the one you chose.

Upvotes: 8

Jem
Jem

Reputation: 2275

In the .NET framework, async methods start with "Begin": BeginDoSomething / DoSomething.

Upvotes: 1

laurent
laurent

Reputation: 90746

How about naming them the same and having a different signature to differentiate them (one with a callback function, one without)?

Otherwise, Adobe uses the "Async" suffix for ActionScript, which seems good enough too: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/FileStream.html

Upvotes: 4

Related Questions