peterbahaa posted on November 11, 2008 19:04

Design Pattern

Following any design pattern is the key of good project development; the website structure must show the business entities and its contents, ex: we are using a mixed design pattern of MVC and N-Tiers , so we need to have each item in place , we didn’t to stuck one specific design pattern , we need to apply what will help developing our project, btw , I was talking to Stephen Forte , “I invented a new design pattern ” , he smile and said back “ Design pattern did get invented it get discovered ” .

Naming Convention

You need to follow any naming convention, but it must be readable and if you run code analysis it will guide you through its rules, ex:

public DataTable SelectCustomerProjects

(

int customerId

, DateTime projectDateFrom

, DateTime projectDateTo

)

{

DataTable myDataTable = new DataTable("myDataTable1");

//......

return myDataTable;

}

Globalization

You need to put all your global functions in Web.Config , also be sure to cast any kind of numbers and dates with Current Culture

Ex: Convert.ToInt32(objectToConvert, CultureInfo.CurrentCulture);

Code analysis will show the write globalization options.

Comments

Write /// up on the function and this will produce the full big comment, ex:

/// <summary>

/// Get Customer's Projects

/// </summary>

/// <param name="customerId"> Cusomter Idenity </param>

/// <param name="projectDateFrom"> Project Starting Date Range From </param>

/// <param name="projectDateTo"> Project Starting Date Range To </param>

/// <returns>Projects of selected customer id or the selected data range in a DataTable</returns>

Resources

Use local and global resources so that your project could be converted to any language easily, (for web development) don’t write anything outside a controls, that won’t get work with resources.

Code Maintainability

Avoid high circular complexity functions , if you run code analysis , any function had circular complexity more than 25 it will produce a warning , so u need to break-down this function into smaller function so it will more maintainable ,

Also avoid writing business logic in presentation layer (UI) because that will make your project hard to get maintained.

Global Error Handling

Avoid writing Try {} catch{} only when u really need them and catch this errors globally by Web.Config “Custom Errors”

<customErrors mode="On" defaultRedirect="~/CustomErrors/Default.aspx" ></customErrors>

Logging

Use Global.asax to Log errors :

void Application_Error(object sender, EventArgs e)

{

// Code that runs when an unhandled error occurs

//Log the Error

}

W3C Standards (For Web Projects)

Check those @ http://www.w3schools.com/w3c/default.asp


Currently rated 5.0 by 3 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Comments

Page List

Calendar

«  March 2010  »
MoTuWeThFrSaSu
22232425262728
1234567
891011121314
15161718192021
22232425262728
2930311234
View posts in large calendar

Blog Roll

    OPMLDownload OPML file

    Authors

    Recent Comments

    Banners

    Disclaimer
    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2010 Peter Bahaa's Blog