码迷,mamicode.com
首页 > Windows程序 > 详细

C# Best Practices - Creating Good Properties

时间:2016-01-12 19:26:10      阅读:201      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!