开发人员手册(VSNET开发规范篇)
- 格式:doc
- 大小:774.50 KB
- 文档页数:49
VisualStudio代码开发指南第一章:Visual Studio的介绍Visual Studio是由微软公司开发的一套集成开发环境(Integrated Development Environment,简称IDE),用于开发各种类型的软件应用程序。
它提供了丰富的功能和工具,旨在帮助开发人员更轻松、高效地编写、调试和部署代码。
1.1 Visual Studio的历史Visual Studio最早发布于1997年,随着时间的推移,它经历了多个版本更新。
每个新版本都带来了更多的功能和改进,以满足开发人员不断变化的需求。
目前最新的版本是Visual Studio 2019,它提供了更加先进和全面的开发工具。
1.2 Visual Studio的特点Visual Studio具有多个独特的特点,使其成为许多开发人员的首选开发环境。
首先,Visual Studio提供了强大的代码编辑功能。
它支持多种编程语言,如C#、C++、等,并且具有智能代码提示、语法高亮和自动格式化等功能,可以帮助开发人员轻松地编写和维护代码。
其次,Visual Studio拥有先进的调试工具。
它提供了功能强大的调试器,可以帮助开发人员找出代码中的错误,并进行逐步调试以解决问题。
除了基本的断点和变量监视功能外,Visual Studio 还支持性能分析、内存分析和多线程调试等高级调试功能。
此外,Visual Studio还具有丰富的可视化设计工具。
开发人员可以使用它来创建用户界面、数据库模型、Web页面等,无需编写大量的代码。
这些可视化工具使开发过程更加直观和高效。
第二章:Visual Studio的安装和配置在开始使用Visual Studio之前,需要先进行安装和配置。
下面是一些基本步骤:2.1 下载和安装Visual Studio可以从官方网站上免费下载。
请确保选择适合您的操作系统和开发需求的版本。
下载完成后,运行安装程序,并按照指示进行安装。
网站项目开发流程及规范Web 开发的分散性和交互性,决定了Web 开发必须遵从一定的开发规范和技术约定,只有每个开发人员都按照一个共同的规范去设计、沟通、开发、测试、部署,才能保证整个开发团队协调一致的工作,从而提高开发工作效率,提升工程项目质量。
一、项目的角色划分如果不包括前、后期的市场推广和产品销售人员,开发团队一般可以划分为项目负责人、程序员、美工三个角色。
项目负责人在我们中国习惯称为"项目经理",负责项目的人事协调、时间进度等安排,以及处理一些与项目相关的其它事宜。
程序员主要负责项目的需求分析、策划、设计、代码编写、网站整合、测试、部署等环节的工作。
美工负责网站的界面设计、版面规划,把握网站的整体风格。
如果项目比较大,可以按照三种角色把人员进行分组。
角色划分是Web项目技术分散性甚至地理分散性特点的客观要求,分工的结果还可以明确工作责任,最终保证了项目的质量。
分工带来的负效应就是增加了团队沟通、协调的成本,给项目带来一定的风险。
所以项目经理的协调能力显得十分重要,程序开发人员和美工在项目开发的初期和后期,都必须有充分的交流,共同完成项目的规划和测试、验收。
二、开发工具的选取不象C/S结构程序开发,可以一门语言从头到尾,你用Delphi,就是Delphi程序员,你用VC++,你就是VC程序员。
B/S结构的Web开发工作,工具的选择是一件痛苦的事情。
从Windows到Linux,从IIS到Apache,从J2EE到 .NET,从COM到.NET到EJB组件……还有Asp、、Jsp、Php、Perl、Javascript、Vbscript……美工也轻松不了多少,什么"网页三剑客" "新网页三剑客"、FrontPage、Photoshop、Co relDraw……谁都说自己是最强大的!我们的经验是,选用工具时最好是统一的,比如美工统一用DreamwaverMX制作网页,程序员全部用文本编辑器书写代码。
Visual C++ .NET入門手冊-使用 .NET V1.0最新版本Visual C++ .NET: A primer for C++ developersAravind CoreraStephen FraserSam GentileNiranjan KumarScott McLeanSimon RobinsonDr P. G. Sarang著黃珮茹 譯第一章Visual C++的新功能為何許多年來 C++ 一直是程式設計中高度被使用的應用軟體和成份。
除了近年來Java的成功之外,當程式的效能被重視時,C++ 仍然是世界上數以萬計程式設計師的選擇。
新版本的Visual Studio恰巧與Microsoft的新.NET Framework一起出版。
新 .NET Framework提供了自然式的語言、建全的網路以及獨立開發環境。
為了配合這種新的發展,Visual Basic昇級為Visual Basic .NET,而ASP 也昇級為ASP .NET。
同時也產生了另一種稱為C#的語言。
為了一群C++ 的程式設計師著想,所以也產生了新的Visual C++ .NET。
因為在過去的幾年中,有相當多的程式是用Visual C++來發展的,所以Microsoft需要確保無論如何發展,程式必須要有向前的包容性。
而且同時C++ 的程式設計師們需要有效的利用這個新的平台。
在這章中我們有兩個目標:由中間的角度去衡量.NET的Framework,以及去檢視Visual 對於寫作C++ 應用軟體時的所產生的新影響。
如同在前言中所提,以及在未來的進度中將提及非常明顯的理由,事實上我們不會想要使用C++來發展新的.NET 應用程式,因為有更好的選擇。
在 .NET 的Framework中,C++的角色在於提供一個決定性的溝通能力,好溝通在 .NET Framework問世前所寫過的和測試過的程式碼,以及未來使用.NET所寫出的應用軟體。
C#编程规范目录第一章概述 (4)规范制定原则 (4)术语定义 (4)Pascal 大小写 (4)Camel 大小写 (4)文件命名组织 (4)1.3.1文件命名 (4)第二章代码外观 (5)2.1列宽 (5)2.2换行 (5)2.3缩进 (5)2.4空行 (5)2.5空格 (5)第三章程序注释 (7)3.4注释概述 (7)3.2文档型注释 (7)3.3类C注释 (8)3.4单行注释 (8)3.5注释标签 (8)第四章申明 (12)4.1每行声明数 (12)4.2初始化 (12)4.3位置 (12)4.4类和接口的声明 (13)4.5字段的声明 (13)第五章命名规范 (14)5.1命名概述 (14)5.2大小写规则 (14)5.3缩写 (15)5.4命名空间 (15)5.5类 (16)5.6接口 (16)5.7属性(A TTRIBUTE) (17)5.8枚举(E NUM) (17)5.9参数 (17)5.10方法 (18)5.11属性(PROPERTY) (18)5.12事件 (19)5.13常量(CONST) (20)5.14字段 (20)5.15静态字段 (21)5.16集合 (22)5.17措词 (22)第六章语句 (23)6.1每行一个语句 (23)6.2复合语句 (23)6.3RETURN 语句 (23)6.4IF、 IF-ELSE、IF ELSE-IF 语句 (23)6.4 FOR、FOREACH 语句 (24)6.5WHILE 语句 (24)6.7.DO - WHILE 语句 (25)6.8.SWITCH - CASE 语句 (25)6.9.TRY - CATCH 语句 (25)6.10. USING 块语句 (26)6.11. GOTO 语句 (26)第七章控件命名规则 (27)7.1命名方法 (27)7.2主要控件名简写对照表 (27)第八章异常处理.................................................................................................. 错误!未定义书签。
About the T utorial.NET Core is the latest general purpose development platform maintained by Microsoft. It works across different platforms and has been redesigned in a way that makes .NET fast, flexible and modern..NET Core happens to be one of the major contributions by Microsoft. Developers can now build Android, iOS, Linux, Mac, and Windows applications with .NET, all in Open Source.AudienceThis tutorial is designed for software programmers who want to learn the basics of .NET Core.PrerequisitesYou should have a basic understanding of Computer Programming terminologies. A basic understanding of any of the programming languages is a plus.Disclaimer & CopyrightCopyright 2018 by Tutorials Point (I) Pvt. Ltd.All the content and graphics published in this e-book are the property of Tutorials Point (I) Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republish any contents or a part of contents of this e-book in any manner without written consent of the publisher.We strive to update the contents of our website and tutorials as timely and as precisely as possible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt. Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of our website or its contents including this tutorial. If you discover any errors on our website or inthistutorial,******************************************.T able of ContentsAbout the Tutorial (i)Audience (i)Prerequisites (i)Disclaimer & Copyright (i)Table of Contents (ii) Core – Overview (1)Characteristics of .NET Core (1)The .NET Core Platform (2) Core – Prerequisites (3) Core – Environment Setup (4)Visual Studio 2015 (4) Core – Getting Started (10) Core – Numerics (13)Integral types (13)Floating-point types (13) Core – Garbage Collection (16)Advantages of Garbage Collection (16)Conditions for Garbage Collection (16)Generations (16) Core – Code Execution (18).NET Core Code Execution Process (19) Core – Modularity (21) Core – Project Files (24) Core – Package References (28) Core – Create UWP App with .NET Core (34) Core – MSBuild (42) Core – Metapackage (47) Core – Windows Runtime and Extension SDKs (53) Core – Create .NET Standard Library (58) Core – Portable Class Library (63)What is PCL (64) Core – Adding References to Library (72) Core – Sharing .NET Core Libraries (77) Core – Creating a Xamarin.Forms Project (87) Core – PCL Troubleshooting (95) Core – Create a Testing Project (105) Core – Running Tests in Visual Studio (109) Core – Testing Library (116) Core – Managed Extensibility Framework (124) Core – .NET Core SDK (134) Core – MSBuild and project.json (140)MSBuild vs project.json (141) Core – Restoring and Building with MSBuild (143) Core – Migrations (147).NET Core is the latest general purpose development platform maintained by Microsoft. It works across different platforms and has been redesigned in a way that makes .NET fast, flexible and modern. This happens to be one of the major contributions by Microsoft. Developers can now build Android, iOS, Linux, Mac, and Windows applications with .NET, all in Open Source.In this tutorial, we will cover .NET Core and a few new innovations including the .NET Framework updates, .NET Standard, and Universal Windows Platform updates, etc.Characteristics of .NET CoreThe following are the major characteristics of .NET Core:Open source∙.NET Core is an open source implementation, using MIT and Apache 2 licenses.∙.NET Core is a .NET Foundation project and is available on GitHub.∙As an open source project, it promotes a more transparent development process and promotes an active and engaged community.Cross-platform∙Application implemented in .NET Core can be run and its code can be reused regardless of your platform target.∙It currently supports three main operating systems (OS):o Windowso Linuxo MacOS∙The supported Operating Systems (OS), CPUs and application scenarios will grow over time, provided by Microsoft, other companies, and individuals.Flexible deployment∙There can be two types of deployments for .NET Core applications:o Framework-dependent deploymento Self-contained deployment4.NET Core5∙ With framework-dependent deployment, your app depends on a system-wide version of .NET Core on which your app and third-party dependencies are installed.∙With self-contained deployment, the .NET Core version used to build your application is also deployed along with your app and third-party dependencies and can run side-by-side with other versions.Command-line tools∙All product scenarios can be exercised at the command-line.Compatible∙.NET Core is compatible with .NET Framework, Xamarin and Mono, via the .NET Standard Library.Modular∙ .NET Core is released through NuGet in smaller assembly packages.∙ .NET Framework is one large assembly that contains most of the core functionalities. ∙ .NET Core is made available as smaller feature-centric packages.∙ This modular approach enables the developers to optimize their app by including just those NuGet packages which they need in their app.∙The benefits of a smaller app surface area include tighter security, reduced servicing, improved performance, and decreased costs in a pay-for-what-you-use model.The .NET Core Platform.NET Core Platform contains the following main parts:∙ .NET Runtime : It provides a type system, assembly loading, a garbage collector, native interop and other basic services.∙ Fundamental Libraries : A set of framework libraries, which provide primitive data types, app composition types and fundamental utilities.∙ SDK & Compiler : A set of SDK tools and language compilers that enable the base developer experience, available in the .NET Core SDK.∙‘dotnet’ app host : it is used to launch .NET Core apps. It selects the runtime and hosts the runtime, provides an assembly loading policy and launches the app. The same host is also used to launch SDK tools in much the same way..NET Core6In this chapter, we will discuss the various dependencies that you need to deploy and run. These include the .NET Core applications on Windows machines that are developed using Visual Studio.Supported Windows Versions.NET Core is supported on the following versions of Windows:∙ Windows 7 SP1 ∙ Windows 8.1 ∙ Windows 10∙ Windows Server 2008 R2 SP1 (Full Server or Server Core) ∙ Windows Server 2012 SP1 (Full Server or Server Core) ∙ Windows Server 2012 R2 SP1 (Full Server or Server Core) ∙Windows Server 2016 (Full Server, Server Core or Nano Server)Dependencies∙If you are running your .NET Core application on Windows versions earlier than Windows 10 and Windows Server 2016, then it will also require the Visual C++ Redistributable.∙ This dependency is automatically installed for you if you use the .NET Core installer. ∙You need to manually install the Visual C++ Redistributable for Visual Studio 2015 if you are installing .NET Core via the installer script or deploying a self-contained .NET Core application.∙For Windows 7 and Windows Server 2008 machines, you need to make sure that your Windows installation is up-to-date and also includes hotfix KB2533623 installed through Windows Update.Prerequisites with Visual Studio∙ To develop .NET Core applications using the .NET Core SDK, you can use any editor of your choice.∙However, if you want to develop .NET Core applications on Windows using Visual Studio, you can use the following two versions:o Visual Studio 2015 o Visual Studio 2017 RC.NET Core7Projects created with Visual Studio 2015 will be project.json-based by default while projects created with Visual Studio 2017 RC will always be MSBuild-based.In this chapter, we will discuss the Environment Setup of .NET Core. It is a significant redesign of the .NET Framework. To use .NET Core in your application, there are two versions you can use:∙Visual Studio 2015∙Visual Studio 2017 RCVisual Studio 2015To use Visual Studio 2015, you must have installed the following;∙Microsoft Visual Studio 2015 Update 3∙Microsoft .NET Core 1.0.1 - VS 2015 Tooling Preview 2Microsoft provides a free version of visual studio which also contains the SQL Server and can be downloaded from https:///en-us/downloads/download-visual-studio-vs.aspx and Microsoft .NET Core 1.0.1 - VS 2015 Tooling Preview 2 can be downloaded from https:///fwlink/?LinkId=817245.You can also follow the installation guidelines on the following Url https:///net/core/#windowsvs2015.Installation of Visual Studio 2015Follow these steps to install Visual Studio 2015:Step 1: Once the downloading completes, then run the installer. The following dialog box will be displayed.89Step 2: Click Install to start the installation process.Step 3: Once the installation completes, you will see the following dialog box.Step 4: Close this dialog and restart your computer if required.10Step 5: Open Visual Studio from the Start Menu; you will receive the following dialog box. It may take a few minutes to load and finally be used for the first time.Step 6: Once it is loaded, you will see the following screen.11Step 7: Once Visual Studio installation is finished, then close Visual Studio and launch Microsoft .NET Core - VS 2015 Tooling Preview 2.Step 8: Check the checkbox and click Install.12Step 9: Once the installation completes, you will see the following dialog box.You are now ready to start your application using .NET Core.Visual Studio 2017In this tutorial, we will be using Visual Studio 2015, but if you want to use Visual Studio 2017, an experimental release of .NET Core tools for Visual Studio is included in Visual Studio 2017 RC and you can see the installation guidelines here https:///net/core/#windowsvs2017.13Visual Studio 2015 provides a full-featured development environment for developing .NET Core applications. In this chapter, we will be creating a new project inside Visual Studio. Once you have installed the Visual Studio 2015 tooling, you can start building a new .NET Core Application.In the New Project dialog box, in the Templates list, expand the Visual C# node and select .NET Core and you should see the following three new project templates: ∙Class Library (.NET Core)∙Console Application (.NET Core)∙ Core Web Application (.NET Core)In the middle pane on the New Project dialog box, select Console Application (.NET Core) and name it "FirstApp", then click OK.14Visual Studio will open the newly created project, and you will see in the Solution Explorer window all of the files that are in this project.To test that .NET core console application is working, let us add the following line.Now, run the application. You should see the following output.1617.NET Core supports the standard numeric integral and floating-point primitives. It also supports the following types:∙ System.Numerics.BigInteger which is an integral type with no upper or lower bound. ∙ plex is a type that represents complex numbers.∙A set of Single Instruction Multiple Data (SIMD)-enabled vector types in the System.Numerics namespace.Integral types.NET Core supports both signed and unsigned integers of different ranges from one byte to eight bytes in length. All integers are value types.The following table represents the integral types and their size;Each integral type supports a standard set of arithmetic, comparison, equality, explicit conversion, and implicit conversion operators.You can also work with the individual bits in an integer value by using the System.BitConverter class.Floating-point types.NET Core includes three primitive floating point types, which are shown in the following table.∙Each floating-point type supports a standard set of arithmetic, comparison, equality, explicit conversion, and implicit conversion operators.∙You can also work with the individual bits in Double and Single values by using the BitConverter class.∙The Decimal structure has its own methods, Decimal.GetBits and Decimal.Decimal(Int32()), for working with a decimal value's individual bits, as well as its own set of methods for performing some additional mathematical operations.BigInteger∙System.Numerics.BigInteger is an immutable type that represents an arbitrarily large integer whose value in theory has no upper or lower bounds.∙The methods of the BigInteger type is closely parallel to those of the other integral types.Complex∙The plex type represents a complex number, i.e., a number witha real number part and an imaginary number part.∙It supports a standard set of arithmetic, comparison, equality, explicit conversion, and implicit conversion operators, as well as mathematical, algebraic, and trigonometric methods.SIMD∙The Numerics namespace includes a set of SIMD-enabled vector types for .NET Core.∙SIMD allows some operations to be parallelized at the hardware level, which results in huge performance improvements in mathematical, scientific, and graphics apps that perform computations over vectors.∙The SIMD-enabled vector types in .NET Core include the following:o System.Numerics.Vector2, System.Numerics.Vector3, and System.Numerics.Vector4 types, which are 2, 3, and 4-dimensional vectors oftype Single.o The Vector<T> structure that allows you to create a vector of any primitive numeric type. The primitive numeric types include all numeric types in theSystem namespace except for Decimal.18o Two matrix types, System.Numerics.Matrix3x2, which represents a 3x2 matrix;and System.Numerics.Matrix4x4, which represents a 4x4 matrix.o The System.Numerics.Plane type, which represents a three-dimensional plane, and the System.Numerics.Quaternion type, which represents a vector that is used to encode three-dimensional physical rotations.19.NET Core20 In this chapter, we will cover the concept of Garbage collection which is one of most important features of the .NET managed code platform. The garbage collector (GC) manages the allocation and release of memory. The garbage collector serves as an automatic memory manager.∙You do not need to know how to allocate and release memory or manage the lifetime of the objects that use that memory. ∙An allocation is made any time you declare an object with a “new” keyword or a value type is boxed. Allocations are typically very fast. ∙When there isn’t enough memory to allocate an object, the GC must collect and dispose of garbage memory to make memory available for new allocations. ∙ This process is known as garbage collection .Advantages of Garbage CollectionGarbage Collection provides the following benefits:∙You don’t need to free memory manually while developing your application. ∙It also allocates objects on the managed heap efficiently. ∙When objects are no longer used then it will reclaim those objects by clearing their memory, and keeps the memory available for future allocations. ∙Managed objects automatically get clean content to start with, so their constructors do not have to initialize every data field. ∙ It also provides memory safety by making sure that an object cannot use the content of another object.Conditions for Garbage CollectionGarbage collection occurs when one of the following conditions is true.∙The system has low physical memory. ∙The memory that is used by allocated objects on the managed heap surpasses an acceptable threshold. This threshold is continuously adjusted as the process runs. ∙ The GC.Collect method is called and in almost all cases, you do not have to call thismethod, because the garbage collector runs continuously. This method is primarily used for unique situations and testing..NET Core21 GenerationsThe .NET Garbage Collector has 3 generations and each generation has its own heap that that is used for the storage of allocated objects. There is a basic principle that most objects are either short-lived or long-lived.Generation First (0)∙In Generation 0, objects are first allocated. ∙In this generation, objects often don’t live past the first generation, since they are no longer in use (out of scope) by the time the next garbage collection occurs. ∙ Generation 0 is quick to collect because its associated heap is small.Generation Second (1)∙In Generation 1, objects have a second chance space. ∙Objects that are short-lived but survive the generation 0 collection (often based on coincidental timing) go to generation 1. ∙Generation 1 collections are also quick because its associated heap is also small. ∙ The first two heaps remain small because objects are either collected or promoted to the next generation heap.Generation Third (2)∙In Generation 2, all long objects are lived and its heap can grow to be very large. ∙The objects in this generation can survive a long time and there is no next generation heap to further promote objects. ∙The Garbage Collector has an additional heap for large objects known as Large Object Heap (LOH). ∙It is reserved for objects that are 85,000 bytes or greater. ∙Large objects are not allocated to the generational heaps but are allocated directly to the LOH. ∙Generation 2 and LOH collections can take noticeable time for programs that have run for a long time or operate over large amounts of data. ∙Large server programs are known to have heaps in the 10s of GBs. ∙The GC employs a variety of techniques to reduce the amount of time that it blocks program execution. ∙The primary approach is to do as much garbage collection work as possible on a background thread in a way that does not interfere with program execution. ∙The GC also exposes a few ways for developers to influence its behavior, which can be quite useful to improve performance.In this chapter, we will understand the execution process of .NET Core and compare it with the .NET Framework. The managed execution process includes the following steps.∙Choosing a compiler∙Compiling your code to MSIL∙Compiling MSIL to native code∙Running codeChoosing a Compiler∙It is a multi-language execution environment, the runtime supports a wide variety of data types and language features.∙To obtain the benefits provided by the common language runtime, you must use one or more language compilers that target the runtime.Compiling your code to MSIL∙Compiling translates your source code into Microsoft Intermediate Language (MSIL)and generates the required metadata.22∙Metadata describes the types in your code, including the definition of each type, the signatures of each type's members, the members that your code references, and other data that the runtime uses at execution time.∙The runtime locates and extracts the metadata from the file as well as from framework class libraries (FCL) as needed during execution.23End of ebook previewIf you liked what you saw…Buy it from our store @ https://24。
以下是本人对.Net平台开发实践的一些点滴总结。
这里的技术规范主要是开发过程的代码规范、数据库设计规范、Com和.Net互操作规范;实践精华是对技术实践过程中的部分总结。
一、代码规范良好的代码风格来自于同一的代码规范。
风格良好的代码不仅具备可读性和可维护性,同时也给人行云流水、赏心悦目之快感。
据Microsoft公司统计,基于微软平台的开发中,有70-80%的印度工程师在完成同类算法或者模块时,使用的代码基本一致;而相同的调查中只有20%的中国工程师们是基本一致的。
这说明我们的代码生产过程亟待规范。
实义命名类型、变量、常量、方法等标识符一律采用对应的英文实义;如果涉及到两个独立的实义单词,则中间用下划线间隔或者单词首字母大写(两种方式都可以);如果标识符的长度超过了30个字母,则基本上以英文单词发音的重读音节取选出三个字母,如Repeater用rpt,Management用 mgt。
大小写规则目前一般有两种大小写规则:Pascal大小写形式,所有单词第一个字母大写,其他字母小写。
Camel大小写形式,除了第一个单词,所有单词第一个字母大写,其他字母小写。
类名使用Pascal大小写形式方法使用Pascal大小写形式变量和方法参数使用Camel 大小写形式不要使用匈牙利方法来命名变量以前,多数程序员喜欢把数据类型作为变量名的前缀而m_作为成员变量的前缀。
例如: string m_sName;int nAge;然而,这种方式在.NET编码规范中是不推荐的。
所有变量都用Camel 大小写形式,而不是用数据类型和m_来作前缀。
用name,address,salary等代替nam,addr,sal。
别使用单个字母的变量象i,n,x 等。
使用 index,temp等。
用于循环迭代的变量例外:如果变量只用于迭代计数,没有在循环的其他地方出现,允许用单个字母的变量命名,而不是另外取实义名。
文件名要和类名匹配,例如,对于类HelloWorld,相应的文件名应为helloworld.cs。
密级:秘密开发人员手册开发规范篇文档最后修订者及日期:孙立新2009-3-16本版文件批准人及日期:浪潮集团山东通用软件有限公司目录1导言41.1目的41.2适用范围41.3术语定义41.4参考资料41.5版本更新记录42使用的开发工具:53程序源代码风格定义53.1代码结构风格53.2注释风格63.2.1单行注释73.2.2多行注释73.2.3文档型注释73.2.4文档型注释规范93.3代码书写风格133.3.1缩进133.3.2空行143.3.3换行143.3.4空格153.3.5花括号154命名规范164.1大写规则164.2区分大小写174.3缩写184.4措词194.5避免类型名称混淆204.6命名空间命名规范214.7类命名规范234.8接口命名规范234.9属性命名规范244.10枚举类型命名规范244.11静态字段命名规范254.12参数命名规范294.13方法命名规范284.14属性命名规范264.15事件命名规范294.16数据库对象命名规范304.16.1数据库名(开发过程中)304.16.2数据库表304.16.3字段314.16.4存储过程命名约定324.16.5触发器(插入,更新,删除)命名约定324.16.6视图命名约定324.16.7自定义数据类型命名约定334.16.8自定义函数命名约定344.17数据库表结构设计规范344.18数据库存储过程编写规范355界面规范355.1总则355.2遵从原则365.3色彩搭配365.4屏幕大小365.5主控页面365.5.1主页:登录窗口365.5.2主操作页分成三个区域:标题菜单区、系统经管区、操作区375.5.3浏览器385.6各种页面模板应用的场景385.6.1字典类385.6.2单据类405.6.3经管类415.6.4索引类425.6.5Tab页类425.6.6响应式窗口类425.6.7查询结果/报表类426提示信息规范426.1总则426.2提示信息427热键定义、帮助及使用规范437.1总则437.2规范438单元测试规范(从开发人员角度)448.1总则448.2测试规范449配置经管规范(从开发人员角度)459.1总则459.2开发前的准备459.3开发过程中的规则4510程序模板4610.1总则4610.2字典模板4710.3单据模板4710.4查询模板4711其他规则及建议481导言1.1目的本文档是为基于Microsoft®公司的Visual Studio .Net® - C#.Net系列开发工具进行软件开发的一个规范性文件。
.NET开发规范编写:审核:批准:目录1.概述 (4)2.命名规范 (4)2.1.类、参数和方法的命名规范 (4)2.2.接口命名规范 (4)2.3.动态语言文件命名规则 (5)2.3.1.格式:性质_描述 (5)2.4.客户端JavaScript规范 (5)2.4.1.变量命名规范 (5)2.4.2.对象命名规范 (5)2.5.控件命名规范 (5)2.6.图片的命名原则 (6)2.7.数据库命名规范 (7)2.7.1.命名规范原则 (7)2.7.2.数据库规范 (7)2.7.3.表命名规范 (7)2.7.4.字段规范 (8)2.7.5.视图规范 (8)2.7.6.存储过程规范 (8)2.7.7.函数规范 (8)2.7.8.索引命名规范 (8)2.7.9.关联命名 (8)2.7.10.设计规范 (8)3.编码规范 (8)3.1.C#代码编写 (8)3.2.Request、Session、Application使用规范 (12)3.3.HTML标记语言编码规范 (12)3.4.注释规范 (12)3.5.异常规范 (15)1.概述为了保持应用程序、组件、文件的一致性,便于阅读和管理代码和结构,提高开发效率和产品的标准化,特制订一套开发规范和标准(包括命名规范和编码规范)。
命名规范将包括:类和参数的命名规范、接口命名规范、数据库命名规范、ASP命名规范、JavaScript命名规范、控件命名规范等。
编码规范将包括:C#编码规范、注释规范、HTML编码规范、编码规范、异常规范等。
2.命名规范2.1.类、参数和方法的命名规范2.1.1.用名词或名词短语命名类。
2.1.2.使用Pascal大写注记:Pascal 大小写形式-所有单词第一个字母大写,其他字母小写。
2.1.3.不要使用匈牙利命名法2.1.4.用有意义的,描述性的词语来命名变量- 别用缩写。
用name, address, salary等代替nam, addr, sal 。
密级:秘密开发人员手册开发规范篇文档最后修订者及日期:孙立新2009-3-16本版文件批准人及日期:浪潮集团山东通用软件有限公司目录1导言 (5)1.1目的 (5)1.2适用范围 (5)1.3术语定义 (5)1.4参考资料 (5)1.5版本更新记录 (5)2使用的开发工具: (6)3程序源代码风格定义 (6)3.1代码结构风格 (6)3.2注释风格 (7)3.2.1单行注释 (8)3.2.2多行注释 (8)3.2.3文档型注释 (8)3.2.4文档型注释规范 (10)3.3代码书写风格 (14)3.3.1缩进 (14)3.3.2空行 (15)3.3.3换行 (15)3.3.4空格 (16)3.3.5花括号 (16)4命名规范 (17)4.1大写规则 (17)4.2区分大小写 (18)4.3缩写 (19)4.4措词 (20)4.5避免类型名称混淆 (21)4.6命名空间命名规范 (22)4.7类命名规范 (24)4.8接口命名规范 (24)4.9属性命名规范 (25)4.10枚举类型命名规范 (25)4.11静态字段命名规范 (26)4.12参数命名规范 (30)4.13方法命名规范 (29)4.14属性命名规范 (27)4.15事件命名规范 (30)4.16数据库对象命名规范 (31)4.16.1数据库名(开发过程中) (31)4.16.2数据库表 (32)4.16.3字段 (32)4.16.4存储过程命名约定 (33)4.16.5触发器(插入,更新,删除)命名约定 (33)4.16.6视图命名约定 (33)4.16.7自定义数据类型命名约定 (34)4.16.8自定义函数命名约定 (35)4.17数据库表结构设计规范 (35)4.18数据库存储过程编写规范 (36)5界面规范 (37)5.1总则 (37)5.2遵从原则 (37)5.3色彩搭配 (37)5.4屏幕大小 (37)5.5主控页面 (37)5.5.1主页:登录窗口 (37)5.5.2主操作页分成三个区域:标题菜单区、系统管理区、操作区 (38)5.5.3浏览器 (39)5.6各种页面模板应用的场景 (39)5.6.1字典类 (39)5.6.2单据类 (41)5.6.3管理类 (42)5.6.4索引类 (43)5.6.5Tab页类 (43)5.6.6响应式窗口类 (43)5.6.7查询结果/报表类 (43)6提示信息规范 (43)6.1总则 (43)6.2提示信息 (43)7热键定义、帮助及使用规范 (44)7.1总则 (44)7.2规范 (44)8单元测试规范(从开发人员角度) (45)8.1总则 (45)8.2测试规范 (45)9配置管理规范(从开发人员角度) (46)9.1总则 (46)9.2开发前的准备 (46)9.3开发过程中的规则 (46)10程序模板 (47)10.1总则 (47)10.2字典模板 (47)10.3单据模板 (48)10.4查询模板 (48)11其他规则及建议 (49)1导言1.1目的本文档是为基于Microsoft®公司的Visual Studio .Net® - C#.Net系列开发工具进行软件开发的一个规范性文件。
其目的是:➢保证软件开发过程中有一个统一的标准可以进行参照:包括类库、公共接口、设计模式、命名规范等。
➢能够合理的使用公用资源1.2适用范围本文档主要是基于目前三层架构开发模式中的SmartClient方式进行描述的,并同样适合于传统的三层架构:/BusinessIntegration/Database。
1.3术语定义可访问性修饰符:public(公有)、internal(内部公有)、proected(受保护)、protected internal(受保护或内部公有)、private(私有)。
在此约定好中英文对照名称。
非私有包括:公有、内部公有、受保护、受保护或内部公有。
1.4参考资料1.《C# Language Specification1.2.doc》2.《C# Language Specification 2.0.doc》1.5版本更新记录2使用的开发工具:➢Microsoft® Visual Studio .Net 2005® - C#.Net3程序源代码风格定义源代码风格规范是在编写源代码文件时,对于书写格式和规则的统一要求。
编写源代码最基本的目标是能够经过编译生成可执行程序。
此外,源代码的另一个主要目标是为了阅读,源代码不仅仅是为了编译器能够读懂,同时也是为了人能够读懂,且易于读懂。
这就如写文章的句读、段落、章节等类似,如果没有一种良好的书写风格和习惯,不仅仅会使写出的文章难以阅读,而且可能会造成不少曲解。
有句话叫“文如其人”,代码也同样是“文如其人”。
此外,作为一个协作密切的开发团队,非常有必要保持一致的代码书写风格,它有助于团队开发保持高效(沟通交流、代码阅读、工作交接、工作延续性等方面)。
3.1代码结构风格对于每一个代码文件(*.cs),它的内容分为如下两个部分:◆使用的命名空间◆类型定义使用的命名空间,要求必须都声明在代码文件的最前方。
建议.net framework 中定义的命名空间放在最上面,然后根据与当前代码关系的远近依次排列,对于引用的命名空间,按照引用来源分段列示,段与段之间用空行分隔。
示例图如下:在类型定义部分,一个代码文件原则上只包含一个如下类型的定义:类、接口、结构、枚举。
这样有利于构造出条理清晰的代码文件结构,一目了然。
对于委托的定义,可考虑在一个代码文件中集中定义内聚度较高的一类枚举。
对于类的定义,按照一下顺序定义:◆常量◆字段◆构造函数◆析构函数◆属性◆方法◆事件所有的类成员必须显式的声明访问修饰限定符(public、internal、protected、private)。
为使类型具有良好的封装性,其中字段类型只能声明为private。
对于接口和结构体定义,其成员声明顺序与类定义相同。
每行代码只允许写一条语句。
每行代码写多条语句往往会造成调试定位、注释以及阅读的困难。
3.2注释风格传统的注释风格:单行注释符号“//”和多行注释符号“/* */”在C#中依然可以使用。
在.NET中,提供了额外的XML文档注释标记(Tags forDocumentation Comments)。
3.2.1单行注释单行注释,即形式为“//”的注释。
单行注释用于方法内的代码注释。
如对局部变量声明的注释或代码行、代码段的注释。
单行注释可单独一行,如果仅仅针对一句注释,且不影响换行,可放于代码行后部。
单行注释也可以用于临时屏蔽不用的代码行,在开发完毕后应及时清理。
特殊的,单行注释用于代码文件声明的注释,见代码文件注释。
3.2.2多行注释多行注释,即形式为“/* */”的注释。
一般的,不建议在代码中使用多行注释。
多行注释可用于临时屏蔽不用的代码行,在开发完毕后应及时清理。
3.2.3文档型注释文档型注释,即XML文档注释标记(Tags for Documentation Comments),该类注释是.Net定义的Xml标签,在声明接口、类、方法、属性、字段都应该使用该类注释,除了在阅读代码时了解代码语义之外,可通过该类注释生成代码类库的帮助文档(*.chm)。
这些标记包括如下表的全部内容:3.2.4注释规范3.2.4.1代码文件注释对于每一个代码文件(*.cs),在文件起始位置添加注释,用以声明该代码文件的用途、版本修订历史、作者、创建日期以及版权声明等信息。
3.2.4.2类型定义注释在类型定义时,需要添加该类型的功能用途说明的注释。
用途说明应为阅读者介绍该类型提供的主要功能,并向使用者介绍该类使用时需要了解的知识,不要泛泛而谈,内容空洞,应付了事。
使用“<summary/>”标签,内部可根据需要添加适当的标签,以便更清楚的表达。
生成的类库文档样式示例:3-4 类型定义注释生成文档样式示例3.2.4.3成员声明注释在类的内部,对于成员的声明,注释应能够说明成员的功能用途,如果成员带有参数和返回值,应说明相应的含义。
功能用途使用“<summary/>”标签。
参数使用“<param/>”标签,返回值使用“<returns/>”标签,另可根据成员的的调用应注意的问题和相关知识进行说明,可采用“<remarks/>”标签进行备注说明,采用“<example/>”标签提供编程Demo。
示例如下:///<summary>///获取指定配置的安全管理服务调用接口。
///</summary>///<param name="configID">配置标识。
对应于配置项中的<strong>Code</strong>属性。
</param>///<returns>安全管理服务调用接口。
</returns>///<exception cref="SecurityException">如果是程序识别的错误,将会抛出该类型的异常。
</exception>///<remarks>///当前程序已经提供了三种服务调用实现,分别是:“本地调用(Local)”、“Web服务调用(WS)”、“Remoting调用(Remoting)”。
///</remarks>///<example><code>/// ISecurityServiceClient serviceClient =/// SecurityClientFactory.GetClient(SecurityClientFactory.WebService);///</code></example>public static ISecurityServiceClient GetClient(string configID)3-5 类型定义注释代码示例生成的类库文档样式示例:3-6 类型定义注释生成文档样式示例3.2.4.4代码段注释位于属性方法、成员方法内部代码实现,一般使用单行注释形式。
示例如下:3.3代码书写风格以下是经常使用到的一些代码格式要求:3.3.1缩进缩进是通过在每一行代码的前端添加一定数量的显示为空白的符号,在显示上区分出代码行之间的层次关系。
一个缩进单位是4个空格符(不要直接使用Tab字符,设置:工具->选项->文本编辑器->C#->制表符->插入空格)。