首页 > Windows开发 > 详细

C# Best Practices - Creating Good Properties

时间:2016-01-12 19:25:39      阅读:352      评论:0      收藏:0      [点我收藏+]

Coding Properties

Code in the Getter

Check the user‘s credentials

Check application state

Format the returned value

Log

Lazy Loading related data/object

Code in the Setter

Check the user‘s credentials

Check application state

Validate the incoming value

Log or change tracking

Format, convert, clean up

Best Practices

Do:

Add code in the getter to protect, format, initialize,...

Add code in the setter to protect, format, validate,...

Avoid:

Single character name

Abbreviations

Easy Way to Create

prop

propfull

C# Best Practices - Creating Good Properties

原文:http://www.cnblogs.com/lmfy/p/5125236.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!