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 ...
随机推荐
- 官方原版Adobe Acrobat XI Pro v11.0.0 序列号激活 可升级更新
使用本人制作的正版激活向导,可以直接使用 注册机算号激活Adobe Acrobat XI Pro11 激活后可以直接官网升级更新软件,永久使用.下面是激活程序界面.简单易懂,傻瓜式操作.带有详细的安装 ...
- AIDL 发生异常的原因 Android java.lang.SecurityException: Binder invocation to an incorrect interface
我建立了两个project.一个是activity 的 ,一个是service 的. 在进行两个project通信时,应该有以下几点注意: 1.在activity project中引入service ...
- ASPxGridView-单元格合并
<dx:ASPxGridView ID="gridView" runat="server" ClientInstanceName="gvResu ...
- 获取 web容器中的bean
public class WebContextBeanFinder { public static Object getBean(String beanId) { ServletContext ser ...
- Lc.exe已退出 代码为-1问题解决方法
对于用vs作为开发工具的同学来说,可能常常会碰到“Lc.exe已退出 代码为-1”的问题,造成这个结果的一般是因为加入了第三方的插件程序造成的,今天一一讲解如何解决. 工具/原料 vs各版本开发工具 ...
- C++_前置声明
为什么要有前置声明? eg: -定义一个类 class A,这个类里面使用了类B的对象b,然后定义了一个类B,里面也包含了一个类A的对象a,就成了这样: //a.h #include "b. ...
- STL模板_map
map -key - value -键值无法重复 multimap -键值可以重复 声明: -map<int, string> m -multimap<int, string> ...
- A - A
A - A Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Status ...
- Linux学习之crontab定时任务
为当前用户创建cron服务 1. 键入 crontab -e 编辑crontab服务文件 例如 文件内容如下: */2 * * * * /bin/sh /home/admin/jiaoben/bu ...
- 汉化testlink
testlink版本:1.9.13 1.登录testlink后,打开my setting(左上角小人人) 2.Locale 选择chinese,然后点击save 3.over,汉化完毕