PeterBox Homepage
Hallo, willkommen auf Singapur, 9.9.10 15:14:11

.NET Development Handbook

.NET Development Handbook .NET Development Handbook .NET Development Handbook .NET Development Handbook
.NET Development Handbook

3 General Guidelines

3.1Documentation
3.1.1File Header Comments
3.2Coding Format
3.3Naming Convention
3.3.1Exceptions to MS Guidelines
3.3.2Additional Naming Conventions
3.3.3Abbreviations
3.4General Rules Peer Review
3.5Source Code Control
3.6Development Environment
3.6.1Development Workstations
3.6.2Test PCs
3.6.3Development Database
3.6.4Development Webserver

This chapter introduces general rules applicable to several technologies covered in this document. Technology specific information is provided in the next chapters.

3.1 Documentation

Proper documentation is the prerequisite for future code maintenance. As much documentation as possible should be included in the source code. Additional documents tend to be neglected during upgrades and bug fixes.

3.1.1 File Header Comments

Files headers should include titles, descriptions and copy rights. The change history should not be included, because this can be very cumbersome and is often not up-to-date. The versioning tool can provide this information more accurately and more detailed.

3.2 Coding Format

The following formatting rules apply universally, independently which technology is used (C#, HTML, Stored Procedure, etc.). A good general overview provides the MSDN Library:

.NET Development - Visual Studio .NET. Product Documentation - Developing with Visual Studio .NET - Working with Code, HTML, and Resource Files - Coding Techniques and Programming Practices - Coding Techniques.

General rules:

• Use lower case characters for keywords

• Use 4 spaces for tabs

• Use a space after but not before??挔 ?挔 ??/p>

• Don抰 use spaces before and after ??if the period is used to connect two entities (object.property).

• Use one space before and after binary operators like ???????? In complicate formulas, spaces might be uses to show which calculation is performed first: a*b + c*d or (a+b) * (c+d)

• Use a space before and after an equal sign for assignments: variable = 5, but no spaces for comparisons: if variable=5 then ?/code>. An example for an assignment to a Boolean variable and comparison in the same statement: BooleanFlag = a=b

Technology specific formatting rules are covered in:

3.3 Naming Convention

A naming convention makes code easier to understand and maintain by a group of developers. Use Microsoft抯 Naming Guidelines in MSDN Library - .NET Development - .NET Framework ?Reference - Design Guidelines for Class Library Developers - Naming Guidelines.

For your convenience, I repeat here the most important once:

• Use Pascal style capitalization (FirstLetterCapital) for most names, except parameters, where camel casing (firstLetterSmall) should be used.

• Do not use names which differentiate only in capitalization, even not in C#, which would distinguish between these names. It抯 just too confusing.

• Do not use the underscore character (_), except to mark private fields in classes or to separate to abbreviations: TextHTML_UTF8 ?/p>

• Do not use Hungarian notation prefix: lblFamilyName. Microsoft recommends not to include type information in names, because the IDE can provide this information if needed. However, it seems that programs are sometimes more readable, like. This: FamilyNameLabel, FamilyNameValue This shows clearly that the objects are about a family name, but also differentiates between different elements used to handle a family name.

3.3.1 Exceptions to MS Guidelines

• Do use the underscore character (_),?to mark private fields in classes

3.3.2 Additional Naming Conventions

• Don抰 use just capital letters for abbreviations:

Bad: PBDBException, Better: PBoxDBException

Bad: TextHTMLUTF8, Better: TextHTML_UTF8?or TextHtmlUtf8

3.3.3 Abbreviations

Use abbreviations sparingly and consistently. In .NET, there are thousands of objects and it would be hard to find unique abbreviations for all of them and to remember them. Commonly used abbreviations should be listed in this document.

3.4 General Rules Peer Review

• Code review

- Proper documentation

- Are there enough and understandable comments ? Do the comments correspond with the actual code (sometimes code gets changed, but not the comments)

- Are all parameters tested against missing (null) or illegal values ?

- Proper exception handling

- Checking for completeness of test procedures

• Single stepping through test procedures

3.5 Source Code Control

If more than one person works on a project, source code control software like Visual SourceSafe is needed.

3.6 Development Environment

3.6.1 Development Workstations

The development workstations are used for writing source code and to test it. For ASP.Net development, it runs also IIS locally to allow easy debugging of code under development.

• MSDN Universal Subscription for:

- Windows XP

- Office XP

- Visual Studio .NET

- Visual SourceSafe

- Visio

- Project

- All development server licenses

• Photoshop for Web Developers

• Pentium PC, 512 MByte RAM, 19 inch Monitor

3.6.2 Test PCs

Additional PCs are needed for testing of website with different browsers (ASP.NET), installation and rollout tests (non ASP.NET) and for stress testing (load simulation). They have the same setup as development PCs, maybe less powerful hardware. No software licenses needed (included in MSDN subscription).?

3.6.3 Development Database

Provides each developer with his own test database and a databases for integration, upgrade testing, etc. No software licenses needed (included in MSDN subscription).

3.6.4 Development Webserver

No software licenses needed (included in MSDN subscription). This server is used for integration test, user acceptance test and release test.

Chapters Overview

1Introduction
2Overview Development Process
3General Guidelines
4.NET Framework
5Windows Client
6ASP.NET
7HTML
8Cascading Style Sheets
9ADO.NET
10SQL Server
11Appendix
  Version 0.8b contact@peterbox.com ©2002 Peter Huber