惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
N
Netflix TechBlog - Medium
The Register - Security
The Register - Security
C
Cybersecurity and Infrastructure Security Agency CISA
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The Hacker News
The Hacker News
P
Proofpoint News Feed
Project Zero
Project Zero
The GitHub Blog
The GitHub Blog
The Last Watchdog
The Last Watchdog
F
Fortinet All Blogs
S
Schneier on Security
Help Net Security
Help Net Security
Security Archives - TechRepublic
Security Archives - TechRepublic
C
Check Point Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
P
Proofpoint News Feed
I
InfoQ
T
The Blog of Author Tim Ferriss
Cisco Talos Blog
Cisco Talos Blog
Stack Overflow Blog
Stack Overflow Blog
T
Troy Hunt's Blog
人人都是产品经理
人人都是产品经理
T
Threatpost
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
Cyber Attacks, Cyber Crime and Cyber Security
雷峰网
雷峰网
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
Forbes - Security
Forbes - Security
Vercel News
Vercel News
S
Security Affairs
美团技术团队
P
Privacy & Cybersecurity Law Blog
N
News and Events Feed by Topic
Cyberwarzone
Cyberwarzone
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Jina AI
Jina AI
Spread Privacy
Spread Privacy
Attack and Defense Labs
Attack and Defense Labs
IT之家
IT之家
U
Unit 42
Recorded Future
Recorded Future
W
WeLiveSecurity
PCI Perspectives
PCI Perspectives
P
Palo Alto Networks Blog
H
Hacker News: Front Page
S
Security @ Cisco Blogs
博客园 - 【当耐特】

博客园 - Hex

大辉谈-备战双十一之动静分离实战 [知识库:python-tornado]异步调用中的上下文控制Tornado stack context 在 CentOS 下手工安装 Docker v1.1x Docker: 如何修改 Docker 的镜像存储位置 Docker学习记录3: 搭建 Private Registry - Hex [原创]Docker学习记录: Shipyard+Swarm+Consul+Service Discover 搭建教程 解决mac OS 10.9 下python 在terminal下崩溃的问题 ssh连接失败, 记下来原因和解决方案 centos+nginx+redmine+gitosis安装指南 面向对象控与python内存泄漏 python 之禅:import this 新头衔:热酷高级python软件工程师,你问我去热酷干嘛? 使用AuthToken架构保护用户帐号验证Cookie的安全性 热酷,新的领域,新的发展 恩,终于有我自己的时间整理下这两年的思路了 MouseOut和RollOut的区别 关于VS2008单元测试中加载配置文件的问题 竟然遇到取FormAuthentication的值取不出来的情况 实现一个Ajax模式的文件上传功能有多难?
[思想火花]:函数命名及参数
Hex · 2010-11-19 · via 博客园 - Hex

我倾向于使用语义非常明确的方式命名一个函数,即使这样写下来函数的名字非常长,例如ClearExpiredFriendLatestNotes之类的.

今天调整一个函数,就是定期清理好友最新日记的一个函数,本质上来说,清理用户好友的最新日记加个过期天数就够了,但是我还要清理影响到的用户的好友最新日记缓存,所以考虑到这点,我需要这个函数返回影响到的好友的用户标识集合,但问题是我今天非常非常有精神头,所以我仔细的犹豫了下,到底是将这个好友用户标识集合做为返回数据还是作为out参数处理.分别如下:

方案1:

public abstract List<long> ClearExpiredFriendLatestNotes(int expireDays);

方案2:

public abstract void ClearExpiredFriendLatestNotes(int expireDays,out List<long> effectUsers);

相信大部分同学对这2个函数方案都觉得无所谓,但是我今天很特别的仔细想了下,觉得还是使用方案2比较妥当,原因如下:

1 函数的本质意义是清理过期的好友最新日记集合,也就是说,返回值并不具备体现这个函数的作用.

2 调用这个函数的开发人员必须仔细阅读帮助文档,或者感谢那位设置了编译出xml的而且让你拷贝那份xml文档的开发人员,否则他是不会知道这个函数的返回值是干什么的.而使用out参数,而且参数的名称为effectUsers,从语义上起码让调用者明白,这个函数还有一个附属的参数返回.

ok

不知道大家怎么看?