C# Best Practices - Define Proper Classes
Application Architecture

Define the components appropriately for the application and create project for each one.

What is Class?
3 Things: Visual Things, Business Things (Domain Entities), Application Things (like Logging & Email Generation)
3 Types: User interface classes, Domain entity classes, Library class
Class is a template or mold,specifies the traits or data,specifies the behavior or operations.
类是一种模板或模具,指定了具体数据或者是行为操作等。
Unit Testing
3 Advantages:
Higher Code Quality, Faster and Easier Debugging, Repeatable
Features:
Tests the behavior of a unit of code (often a method), Automated, Defined with code,Identifies errors
Tools:
MSTest, NUnit
Steps:
1.Define the test scenarios, 2.Generate the tests, 3.Execute the tests
Arrange -> Act -> Assert
FAQ
1.Why is a layer architecture important?
Logical components are easier to create,change,extend and maintain
Code are easier to reuse
2.What is a class?
A template for the objects created at runtime
Specifies the data and operations for each entity
3.What are the benefits of unit testing?
Higher quality code,faster and easier debugging,and they are repeatable over the life of the application
类定义中的访问修饰符
无或internal:只能在当前项目中访问类
public:可以在任何地方访问类
abstract或internal abstract:不能实例化,只能供继承之用(只能在当前项目中访问)
public abstract:同上,但可以在任何地方访问
sealed或internel sealed:不能供派生之用,只能实例化(只能在当前项目中访问)
public sealed:同上,但可以在任何地方访问
接口和抽象类
类似:
都不能实例化,都包含可以由派生类继承的成员。
区别:
1、派生类只能继承一个基类,但类可以继承任意多个接口。
2、抽象类的成员可以拥有代码体(即代码实现),而接口成员没有代码体,都必须在使用接口的类上实现。
3、接口成员是公共的,而抽象类的成员可以是private, protected, internal or protected internal。
4、接口不能包含字段、构造函数、析构函数、静态成员或常量。
C# Best Practices - Define Proper Classes的更多相关文章
- C# Best Practices - Building Good Classes
Building a Class The last four refer as members Signature Accessiblity modifier (Default:internal) c ...
- C# Best Practices - Define Fields Appropriately
Backing Fields private string description; private int productId; Features A variable in a class Hol ...
- MapServer Tutorial——MapServer7.2.1教程学习——第一节用例实践:Example1.3 Displaying Classes in a Layer
MapServer Tutorial——MapServer7.2.1教程学习——第一节用例实践:Example1.3 Displaying Classes in a Layer 一.前言 关于第一节的 ...
- [转]50 Tips for Working with Unity (Best Practices)
About these tips These tips are not all applicable to every project. They are based on my experience ...
- Unity 最佳实践
转帖:http://www.glenstevens.ca/unity3d-best-practices/ 另外可以参考:http://devmag.org.za/2012/07/12/50-tips- ...
- ExtJS笔记2 Class System
For the first time in its history, Ext JS went through a huge refactoring from the ground up with th ...
- 6.Type and Member Basics
1.The Different Kinds of Type Members 1.Constants:a symbol that identifies a never-changing data val ...
- Automake
Automake是用来根据Makefile.am生成Makefile.in的工具 标准Makefile目标 'make all' Build programs, libraries, document ...
- Class loading in JBoss AS 7--官方文档
Class loading in AS7 is considerably different to previous versions of JBoss AS. Class loading is ba ...
随机推荐
- lint使用简介
LINT工具是一种软件质量保证工具,许多国外的大型专业软件公司,如微软公司,都把它作为程序检查工具,在程序合入正试版本或交付测试之前一定要保证通过了LINT检查,他们要求软件工程师在使用LINT时要打 ...
- rsyslog start with
startswith Checks if the value is found exactly at the beginning of the property value. For example, ...
- Spring mvc 简单异常配置jsp页面
原文出处:http://howtodoinjava.com/spring/spring-mvc/spring-mvc-simplemappingexceptionresolver-example/ 这 ...
- css学习笔记三
总结一下水平居中和垂直居中的方法,欢迎交流指正,共同进步! 1.水平居中 1.1):行内元素水平居中,在其父类设置text-align:center; 1.2): 块级元素水平居中有三种 第一种:定宽 ...
- SSH整合方案2
[案例3]SSH整合_方案2 ** 案例描述 两个知识点的演示 其一,SSH整合的第二个方案 其二,Spring+JDBC+Struts2 参考代码 31) 使用工程spring4 32 ...
- mac 版本号控制工具SmartSVN7.5.4(破解版)
SmartSVN7.5.4和破解工具,下载地址:http://download.csdn.net/detail/pearlhuzhu/7407319 操作步骤: 1.在MAC上选中smartsvn-m ...
- oracle超过最大游标数异常分析(转贴)
问题描述 Oracle 使用 OPEN_CURSORS 参数指定一个会话一次最多可以打开的游标的数量.超过此数量时,Oracle 将报告 ORA-01000 错误.当此错误传播到 WebLogic S ...
- c#操作word文档之简历导出
前言 1.写这个功能之前,我得说说微软的这个类库,用着真苦逼!是他让我有程序猿,攻城尸的感觉了.首先这个类库,从没接触过,方法与属性都不懂,还没有提示.神啊,我做这功能真是一步一卡,很潇洒啊. 2.这 ...
- UICollectionView 简单的使用和注意事项
UICollectionView 在创建的时候,要给它一个UICollectionViewFlowLayout (不然会崩溃),就像tableview一样,也要为它注册自定义的cell. UIColl ...
- BZOJ 1935: [Shoi2007]Tree 园丁的烦恼( 差分 + 离散化 + 树状数组 )
假如矩阵范围小一点就可以直接用二维树状数组维护. 这道题, 差分答案, 然后一维排序, 另一维离散化然后树状数组维护就OK了. ----------------------------------- ...