zoukankan      html  css  js  c++  java
  • OC基础之方法和参数的命名规范

    以前学过C/C++/Java/C#语言的童鞋可能刚开始对于OC的方法和参数的命名规范大为不爽

    举例来说,如下一个OC方法:

    - (void)tableView:(UITableView *)tableView
    commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
    forRowAtIndexPath:(NSIndexPath *)indexPath

    这个方法,如果在传统的C++编程语言中
    应该是:

    void tableViewCommitEditingStyleForRowAtIndexPath(
        UITableView *tableView,
        UITableViewCellEditingStyle editingStyle,
        NSIndexPath *indexPath);

    OC为了让你能更清楚地知道每个参数是派什么用处, 其实是把方法名给拆分了

    所以,好的命名规范的建议是:

    每个参数名换行,并且让每个参数后面的冒号尽量对齐(如果不麻烦的话:-))

    好的命名规范:

    -  (void)tableView:(UITableView *)tableView
    commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
     forRowAtIndexPath:(NSIndexPath *)indexPath
  • 相关阅读:
    oo第八次作业--5,6,7次作业总结
    OO前三次作业总结
    软工总结
    黄衫感想博客
    软工结对编程博客
    软工第一次阅读
    软工第0次作业
    OO第四次博客
    OO第三次博客
    OO第二次博客
  • 原文地址:https://www.cnblogs.com/davidgu/p/3912032.html
Copyright © 2011-2022 走看看