Code Rules

From RPM Wiki

Table of contents

Files and Folders

XHTML

All pages and controls should render XHTML (http://en.wikipedia.org/wiki/XHTML).

Doctypes

All pages use the transitional XHTML doctype and 1999 html xmlns:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

Except the 2 frameset pages, which use the frameset doctype:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

Attributes

  • Attribute values should be in double quotes.
    • Correct: class="yes"
    • Wrong: class=no class='no'

Tags

  • Tags (not including server controls) should be lowercase.
    • Correct: <a>
    • Wrong <A>
  • Attributes (not including server controls) should be lowercase.
    • Correct: class="yes"
    • Wrong: CLASS="no"
  • All tags must be closed
    • Correct: Hello World! <img src="hello.gif" />
    • Wrong: Hello World! <img src="hello.gif">
  • All user controls that we write for RPM should use an "rpm" TagPrefix
    • Correct: <rpm:CommGrid>
    • Wrong: <uc1:CommGrid>

RPM Style Guidelines

In addition, we have some rules for consistent programming styles.

Server tags

  • Server tags and attributes should be "Assembly definition" case. This means the automatic case generated if your workstation setup is correct.
    • Correct: <asp:Panel ID="test" runat="server"></asp:Panel>
    • Wrong: <ASP:PANEL id="test" RUNAT="server"></ASP:PANEL>
  • Server tag attributes should be closed in double quites.
    • Correct: <asp:Panel ID="test" runat="server"></asp:Panel>
    • Wrong: <asp:Panel ID='test' runat=server></asp:Panel>

ASP.NET

ASPX auto wireup should be false.

<%@ Page language="c#" AutoEventWireup="false" ...

Indent

  • Indents should be used to show nested tags or logic and should be a tab, not spaces.

Comments

  • In ASPX and ASCX page use server comments so they are stripped out durring page render and not sent to the client
    • <%-- ... --%>
  • Reference FogBugz cases using the format "case {n}". Example: "case 1234".
  • This page was last modified 17:25, 18 Feb 2009.
  • This page has been accessed 1391 times.