C# Best Practices - Creating Good Properties

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

时间: 2024-11-08 14:42:42

C# Best Practices - Creating Good Properties的相关文章

Table Properties [AX 2012]

Table Properties [AX 2012] 1 out of 2 rated this helpful - Rate this topic Updated: July 20, 2012 Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012 This topic describes the properties that

【转】SAP HANA学习资料大全[非常完善的学习资料汇总]

Check out this SDN blog if you plan to write HANA Certification exam http://scn.sap.com/community/hana-in-memory/blog/2012/08/27/my-experience-on-hana-certification Videos available at HANA Academy http://www.saphana.com/community/resources/hana-acad

My ECMAScript 7 wishlist

With ECMAScript 6 now feature complete, any further changes to the core of JavaScript will happen in ECMAScript 7. I’m pretty excited about the changes coming in ECMAScript 6 and there are already some great ECMAScript 7 features such as Object.obser

DbContext运行时动态附加上一个dbset

参考 Creating DbSet Properties Dynamically C# code? 1 DbSet<MyEntity> set = context.Set<MyEntity>(); 或 C# code? 1 DbSet set = context.Set( typeof( MyEntity ) ); 或者利用反射,通过实现DbContext的OnModelCreating方法,参考 Dynamically Adding DbSet Properties in DbC

swift 延迟加载

iOS Developer Lazy Initialization with Swift 22 Jun 2014 ? ∞       Lazy initialization (also sometimes called lazy instantiation, or  lazy loading) is a technique for delaying the creation of an object or  some other expensive process until it's need

sqlhelper1

1 using System; 2 using System.Collections.Generic; 3 using System.Text; 4 using System.Data; 5 6 using System.Configuration; 7 using System.Data.Common; 8 using System.Data.SqlClient; 9 10 using Microsoft.Practices.EnterpriseLibrary.Data; 11 using M

Lazy Initialization with Swift

Lazy initialization (also sometimes called lazy instantiation, or lazy loading) is a technique for delaying the creation of an object or some other expensive process until it's needed. When programming for iOS, this is helpful to make sure you utiliz

Spring Data JPA Batch Insertion

转自:https://www.jeejava.com/spring-data-jpa-batch-insertion/ Spring Data JPA Batch Insertion will show you how we can insert a large dataset into a database at once using Spring Data JPA. For this tutorial we will create a Spring Boot project in Eclip

?TestStand API 编程

TestStand?架构?与?TestStand API 精心设计?的?模?块?化?测试?架构?可?提供?极大?的?价值.?灵活?的?通用?架构?可?应用?到?多种?测试?系统?上,?以?延长?测试?系统?的?使用?寿命?并?降低?测试?开发?成本.?TestStand?提供?了?基于?模?块?化?的?平台,?可?简化?测试?系统?及?相应?测试?的?开发?过程.?TestStand?的?强大?之?处?在于?其?开放?式?架构,?用户?可?通过?该?架构?创建?复杂?且?灵活?的?测试?解决?方