I found an interested guide with suggests as 'Standard' for Web Service development, it's really worthy to take reading.
Coding Standards (HTML/ASP/JavaScript)
In general, Web Services uses a form of Hungarian notation for file, table, field, and variable naming where the first letter of the name is lowercase and capital letters are used to divide multiple words in a name (e.g., "itemAdd.asp," "rsStudentList," "mlHours," etc.).
File and folder names
- All folders will contain an index.html (or .shtml, .asp) file.
- Sites should be organized in a logical, hierarchical manner. Do not place all files in a single directory.
- All file names will begin with lowercase letter or a number.
- A letter following a number in a filename will be lowercase (e.g., "2editImage.asp").
- Multiple word names will be separated by a capital letter (e.g., "itemEdit.asp").
- Do not use underscores ("_") or dashes ("-") in file names.
- Do not use spaces in file names.
- Grouped pages will be begin with the same word or string (e.g., "itemAdd", "itemAdded", "itemEdit", "itemEdited"). This makes it easier to find related pages.
- For files that use server side includes (all template-based files), .shtml will be used for the file extension, not .htm or .html.
- Acronyms that are used at the beginning of a file or folder name shall be all lowercase (e.g., "atecStaffList.asp", "imcResources.shtml").
Examples
Right: tlpServices.shtml
Wrong: TLPServices.shtml
Wrong: tLPServices.shtml
Wrong: tlp-services.shtml
Wrong: tlp_services.shtml
Wrong: tlpServices.htm
Wrong: tlpservices.shtml
Standard Folder Names
- Image files should be placed in a folder called "/images/."
- For sites with few images, this folder should reside at the site's root level and contain all of the site's images.
- For sites with many images on many pages at different levels, it may be better to create "images" folders within each subfolder of the site, and place all images used in each subfolder's pages in each "images" folder.
- For sites that use small thumbnail images to represent larger images, all thumbnail images should reside in a "thumbnails" folder within the "images" folder. All thumbnail images should be named exactly the same as the full-size image file.
- Include files should be placed in a folder called "/_include/" in the root directory of the site.
- JavaScript files should be placed in a folder called "/_scripts/" in the root directory of the site.
- CGI script files should be placed in a folder called "/cgi-bin/" in the root directory of the site, or in the directory where the script is used.
- Style sheet files should be placed in a folder called "/_styles/" in the root directory of the site.
- Files used in developing a new site should be placed in a folder called "/_dev/" in the root directory of the site.
Variable Names (JavaScript, ASP)
Variable names will also follow Hungarian notation.
- All variable names will begin with lowercase letter (no numbers).
- Multiple word names will be separated by a capital letter (e.g., "firstName").
- Do not use underscores ("_") or dashes ("-") in variable names.
- Avoid non-descriptive or highly abbreviated variable names; spell out what each variable stands for (e.g., "firstName" not "fn"); "i" or "x" are fine when just running a "for" loop.
HTML/ASP formatting
- All pages, where practical, should be converted to XHTML Transitional and validated.
- All ASP code (including Response.Write statements) should generate valid XHTML.
- The first letter of all words within ASP commands and statements should be capitalized. (e.g. "Do While Not...", "Response.Write(...")
- All connections will use an include file.
- With a few exceptions, all recordset declarations will be placed above the tag at the top of the document.
- All recordset names will begin with "rs" (e.g., "rsItemInfo").
- All pages that use a connection shall close the connection at the end of the page (below the tag).
- All QueryString variables will have an identifier (e.g., "itemEdit.asp?itemID=33", NOT "itemEdit.asp?33").
- Variable, recordset, and querystring identifier names will
- Begin with a lowercase letter
- Use capital letters to divide words within the variable (e.g., "userFirstName")
- Not use underscores
- If the first letter is part of an acronym, the whole acronym will be lowercase (e.g., "sqlString," not "sQLString").
- All but the shortest statements should include some inline documentation explaining their purpose.
- Multi-line statements should be clearly formatted with brackets separated from code: <%
If aspStatement Then
?
?
End If
%>
Cascading Style Sheets
- Style names will be all lowercase (caps are not allowed for XHTML validation), with no underscores.
- Styles shall be used exclusively for formatting (all tags should be removed from all documents).
- Use existing HTML elements as much as possible, do not add classes like .head1 when the existing h1 style will accomplish what's needed.
- Use existing style sheets. Only create new styles when absolutely necessary. Link style sheets using root-based referencing.
- List styles in alphabetical order within style sheets to make maintenance easier.
- Styles created for specific pages will be defined within the page header.
JavaScript
- For validation purposes, all tags must include a type and language. Use type="text/JavaScript". However, do not use language="JavaScript" because it won't validate when the Document Type is XHTML Strict.
- JavaScript variables will follow ASP variable naming conventions.
- All custom JavaScript functions (that are used on only one page) will be placed in the header of the page it is used on.
- Functions that are used on more than one page must be placed in a .js file. Our standard is to place .js files in a root/_scripts/ folder.
- The most commonly used functions are available in centralized JavaScript files. Use root-based referencing to reference these files on your page.
SQL Formatting
- All SQL reserved words will be typed in all caps (e.g., SELECT * FROM tableName WHERE dtStartDate > '3/3/03').
- Multiple table queries will always be declared using JOIN statements. Non-ANSI type multiple table queries are not allowed.
SQL Tables and Fields
- Table and field names will
- Begin with a lowercase letter
- Use capital letters to divide words within the variable (e.g., "userFirstName")
- Not use underscores
- If the first letter is part of an acronym, the whole acronym will be lowercase (e.g., "sqlString", not "sQLString")
- Tables that are grouped together shall begin with the same string (e.g., "atecCheckout", "atecFacility", "atecEquipment").
- Avoid the use of plurals in table names.
- Avoid the use of numbers in table and field names.
- Field names will record the data type of the field in the first character
- String datatypes (char, varChar, etc.) will begin with "s" (e.g. "sFirstName")
- Integer datatypes will begin with "i" (e.g., "iFacilityID"), with the exception of primary key identity fields, which will be named "ID"
- Floating point (decimal) datatypes will begin with "f"
- DateTime datatypes will begin with "dt"
- Bit datatypes will begin with "b"
- Text datatypes will begin with "t"
- All tables will have a primary key identity field named "ID." Do not name this field after the table name (e.g., "ID," not "userListID") since the table will be identified anyway in multiple table queries (e.g., "userList.ID").
- Views and stored procedures will begin with "view" and "proc" respectively to separate them from tables (e.g., "viewCurrentStaff," "procCalcDaysLeft").
4 nhận xét:
Thank you. Worked for me. I'm use for code website.
___________
Tu bep
Sim Vip, sim số đẹp, Sim phong thủy, sim năm sinh, sim giá rẻ
http://simdoanhnhan.vn/
thank you very useful article
it's really useful, thank
MY SITE
Post a Comment