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 ...
随机推荐
- libvirt python binding 变成了一个新项目
http://libvirt.org/git/ $ git clone git://libvirt.org/libvirt-python.git 2013年的事情了. $ git show a7a12 ...
- Jimmy Choo_百度百科
Jimmy Choo_百度百科 Jimmy Choo
- swift3.0 构造器、析构方法(3)
构造和析构是两种特殊的方法,在对象进行初始化的时候 使用构造,在对象的释放操作中,使用析构. 构造器的定义: init (){ //代码 } init(name:String){ //代码 } 在构造 ...
- iOS开发基本须要
iOS开发基本须要 1 准备好对应的硬件和软件配置------基于Intel处理器的Mac操作系统 2 具有C++,Java或其它面向对象编程语言的开发经验 3 最新的iphone SDK的下 ...
- SQL学习之分组数据Group by
简介:"Group By"根据字面上的意思理解,就是根据"By"后面指定的规则对数据进行分组(分组就是将一个数据集按照"By"指定的规则分成 ...
- jQuery Mobile基础
1.安装 在<head></head>标签里边写入以下内容 jQuery Mobile CDN: <head> <meta charset="utf ...
- Kettle 学习笔记
一直用SSIS做ETL,越来越感觉这玩意不是亲生的.因此萌生换ETL工具的想法,不过Kettle社区版没什么调度系统,貌似错误处理也不是很方便,且先了解吧. 本文简略的记录了整个软件的使用流程. 开始 ...
- myeclipse破解教程,对所有版本有效,完美支持32位和64位
破解软件下载地址 执行Run.bat文件,按照以下步骤进行激活: 第一步:输入任意用户名 第二步:点击Systemid... 按钮,自动生成本机器的systemid. 第三步:点菜单Tools-> ...
- jsp-forward跳转
在Web中可以使用<jsp:forward>指令,将一个用户的请求(request)从一个页面传递到另一个页面,即完成跳转的操作. 1.调整前页:tiaozhuan_a.jsp 代码: & ...
- R与数据分析旧笔记(⑦)回归诊断
回归诊断 回归诊断 1.样本是否符合正态分布假设? 2.是否存在离群值导致模型发生较大误差? 3.线性模型是否合理? 4.误差是否满足独立性.等方差.正态分布等假设条件? 5.是否存在多重共线性 正态 ...