这个方法应该命名什么?

时间:2013-09-23 10:16:27

标签: objective-c methods coding-style naming-conventions naming

我有一个方法用块(比如说数据库事务)执行一些操作,有4个不同的条件(2个布尔参数)。在包括Apple的许多约定中,块参数应该是最后一个但我们不应该首先放置bool参数。 您认为我应该如何命名这种方法?

- (void)performDatabaseTransactionWithSynchronously:(BOOL)synchronously
                                 isWritterOperation:(BOOL)isWritter
                                        transaction:(TransactionBlock)block

- (void)performDatabaseTransactionWithSynchronously:(BOOL)synchronously
                                 isWritterOperation:(BOOL)isWritter
                                    withTransaction:(TransactionBlock)block

- (void)performDatabaseTransaction:(TransactionBlock)block
                     synchronously:(BOOL)synchronously
                isWritterOperation:(BOOL)isWritter

还是其他人?

2 个答案:

答案 0 :(得分:1)

我的版本是:

- (void)performDatabaseTransactionSynchronously:(BOOL)synchronously
                              isWriterOperation:(BOOL)isWriter
                                      withBlock:(TransactionBlock)block

答案 1 :(得分:1)

现在我用了

- (BOOL)performDatabaseTransactionWithDeffered:(BOOL)useDeferred
                             isWriterOperation:(BOOL)isWritter
                                         error:(NSError * __autoreleasing *)error
                                    usingBlock:(TransactionBlock)block

- (void)performDatabaseTransactionAsynchronouslyWithDeffered:(BOOL)useDeferred
                                           isWriterOperation:(BOOL)isWriter
                                                 transaction:(TransactionBlock)block
                                                  completion:(CompletionBlock)completion

还有其他答案吗?