博客统计信息

51cto推荐博客
用户名:arthurchen
文章数:94
评论数:119
访问量:51613
无忧币:1029
博客积分:1696
博客等级:6
注册日期:2010-11-28

我的技术圈(0)

更多>>
良好的代码书写格式:适时的代码缩进
2012-02-07 17:12:16
版权声明:原创作品,如需转载,请与作者联系。否则将追究法律责任。

 

刚开始看到这样的代码时候,第一个瞬间是有点将其代码对齐的冲动,好吧,也许是有点强迫症。

  1. // start the slide up animation 
  2. [UIView beginAnimations:nil context:NULL]; 
  3.     [UIView setAnimationDuration:0.3]; 
  4.  
  5.     // we need to perform some post operations after the animation is complete 
  6.     [UIView setAnimationDelegate:self]; 
  7.  
  8.     self.pickerView.frame = pickerRect; 
  9.  
  10.     // shrink the table vertical size to make room for the date picker 
  11.     CGRect newFrame = self.tableView.frame; 
  12.     newFrame.size.height -= self.pickerView.frame.size.height; 
  13.     self.tableView.frame = newFrame; 
  14. [UIView commitAnimations]; 

 可是在同一页面上,又看到了这样的一处类似的代码。

我才瞬间意思到什么。因为这些代码是官方的实例代码。

良好的代码书写格式除了命名之外,必要的格式缩进,能够良好的表达一段功能逻辑代码的开始和结束。

在书写代码的时候,除了if,for语句等的缩进,这种独立功能的写法,委实是比较好的方式,值得好好体会学习。

 

本文出自 “ArthurChen” 博客,转载请与作者联系!

分享至
更多
一键收藏,随时查看,分享好友!
0人
了这篇文章
类别:语言技术圈()┆阅读()┆评论() ┆ 推送到技术圈返回首页

相关文章

文章评论

 
 

发表评论            

【技术门诊】专家解析:软考重点难点及应试技巧
昵  称:
登录  快速注册
验证码:

请点击后输入验证码博客过2级,无需填写验证码

内  容: