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的更多相关文章

  1. C# Best Practices - Building Good Classes

    Building a Class The last four refer as members Signature Accessiblity modifier (Default:internal) c ...

  2. C# Best Practices - Define Fields Appropriately

    Backing Fields private string description; private int productId; Features A variable in a class Hol ...

  3. MapServer Tutorial——MapServer7.2.1教程学习——第一节用例实践:Example1.3 Displaying Classes in a Layer

    MapServer Tutorial——MapServer7.2.1教程学习——第一节用例实践:Example1.3 Displaying Classes in a Layer 一.前言 关于第一节的 ...

  4. [转]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 ...

  5. Unity 最佳实践

    转帖:http://www.glenstevens.ca/unity3d-best-practices/ 另外可以参考:http://devmag.org.za/2012/07/12/50-tips- ...

  6. ExtJS笔记2 Class System

    For the first time in its history, Ext JS went through a huge refactoring from the ground up with th ...

  7. 6.Type and Member Basics

    1.The Different Kinds of Type Members 1.Constants:a symbol that identifies a never-changing data val ...

  8. Automake

    Automake是用来根据Makefile.am生成Makefile.in的工具 标准Makefile目标 'make all' Build programs, libraries, document ...

  9. Class loading in JBoss AS 7--官方文档

    Class loading in AS7 is considerably different to previous versions of JBoss AS. Class loading is ba ...

随机推荐

  1. C语言入门(1)——C语言概述

    1.程序与编程语言 我们使用计算机离不开程序,程序告诉计算机应该如何运行.程序(Program)是一个精确说明如何进行计算的指令序列.这里的计算可以是数学运算,比如通过一些数学公式求解,也可以是符号运 ...

  2. iOS6 旋转

    iOS 6的rotation改变了很多.先来看看官方的描述  http://www.bgr.com/2012/08/06/ios-6-beta-4-change-log-now-available/ ...

  3. c#操作word文档之简历导出

    前言 1.写这个功能之前,我得说说微软的这个类库,用着真苦逼!是他让我有程序猿,攻城尸的感觉了.首先这个类库,从没接触过,方法与属性都不懂,还没有提示.神啊,我做这功能真是一步一卡,很潇洒啊. 2.这 ...

  4. 用例图(UseCase Diagram)—UML图(一)

      从上面的用例图模型,我们可以大致了解用例图所描述的是什么.下面进行详细介绍. 用例图,即用来描述什么角色通过某某系统能做什么事情的图,用例图关注的是系统的外在表现,系统与人的交互,系统与其它系统的 ...

  5. Knuth-Morris-Pratt Algorithm

    Today , 第一次学习KMP Algorithm,其中好多地方还是不能理解的透彻,本文将进一步对 KMP Algorithm 进行学习,搞清楚其中的思想…… First , KMP Algorit ...

  6. BZOJ 1176: [Balkan2007]Mokia( CDQ分治 + 树状数组 )

    考虑cdq分治, 对于[l, r)递归[l, m), [m, r); 然后计算[l, m)的操作对[m, r)中询问的影响就可以了. 具体就是差分答案+排序+离散化然后树状数组维护.操作数为M的话时间 ...

  7. python 缩进导致的问题

    今天写Python 看着没有问题 运行就各种问题 object has no attribute 最后发现 Vim 设置里面有个  tabstop  我设置的是4 应该设置成8

  8. IOS UTI统一类型标识符:判断文件类型通过后缀

    今天在学习文档和数据共享中,首先讲的处理统一类型标识符UTI.第一次见,所以记下来以备之用,首先了解UTI和MIME的概念 1.同一类型标识符(Uniform Type Identifier,UTI) ...

  9. 11-3URLTestDemo实例操作完成URL单元测试

    11-3URLTestDemo 1.File -> New -> Project 在左边模板中选择Visual C#里的Web,对应到的项目类型选择ASP.NET MVC3 Web App ...

  10. java核心技术学习笔记之一程序设计概述

    Java 核心技术之一程序设计概述 一.   Java语言的特点 简单行 :取经于C++,排除了C++不常用的指针.结构等,增加垃圾回收. 面向对象:与C++不同是单继承,但是可以继承多接口.完全面向 ...