asp-ajaxed+ Step 2 Coding standards, directory structure and XHTML structure

62 views
Skip to first unread message

Bunkerbuster

unread,
Oct 8, 2010, 9:47:24 AM10/8/10
to asp-ajaxed
Coding standards
Lewis Moten has written a timeless article about this subject:
http://www.pscode.com/vb/scripts/ShowCode.asp?txtCodeId=6706&lngWId=4
And I always use this to develop applications.

With coding standards the code and application is much more easier to
read and maintain not only by you but also by other developers. When I
first started with Ajaxed I had a difficult time to understand the
code even with the comments. If you do not see if something is a
object or a string ride away, it will be very time consuming to
understand and change something.

So for a naming convention and declaring of variables we can use:
Dim strName - String (Unicode)
Dim binName - String (Ascii)
Dim lngName - Long
Dim intName - Integer
Dim bytName - Byte
Dim clsName - Class
Dim objName – Object
Dim dtmName - Date/Time
Dim varName - Variant
Dim blnName – Boolean
Dim curName – Currency
Dim decName - Decimals
Dim arrName – Array

And within the naming convention you can reserve some names for
specialist task or objects like:

Dim objXML - XML file
Dim objXSL - XSL file
Dim objConn - Server.CreateObject("ADODB.Connection")
Dim objRecord - Server.CreateObject("ADODB.Recordset")
Dim objCommand - Server.CreateObject("ADODB.Command")
Dim objStream - Server.CreateObject("ADODB.Stream")
Dim objFso -
Server.CreateObject(“scripting.FileSystemObject”)

Because vb-script and SQL are not case sensitive, we can use camel
casing. But for the languages JavaScript xml, xpath, xsl, css it is
better not to use any capitalized names and write everything in low
caps (the only exception I can think of is to declare jQuery :) ).

--------------------------------------------------------
The directory structure
There is a lot changed when Moten wrote the article. And for a lot of
reasons it can be better to store your web application on a different
drive (or NAS) then where the web server engine is running, the only
thing you have to do is to create a virtual directory that is linked
to your drive/folder.

But the main setup will look something like this (when you are using
DTAP)
DriveLetter:/Path/PortalName

D:/ajaxedDev (your development environment
D:/ajaxedTest (your test environment)
E:/ajaxedAccep (Your acceptation environment)
F:/ajaxedProd (your production environment)


Within the main structure you will have something like this. Al the
documents are grouped and are easy to find.
-root
--clientscripts
---js
----jQury.js (Main jQuery lib)
----jQury_UI.js (jQuery UI Lib)
----jQury_Addons.js (Collection of usefull jQuery plugins)
--serverscripts
---asp
----apps
----classes
-----clsCookies.asp (cookieclass)
-----clsDatabaseConn.asp (normal db connection)
-----clsDatabaseConnXml.asp (only to extract xml from db)
-----clsDateFormat.asp (date and time cleanup / format)
----includes
-----config.asp (config files website)
---xsl
----master.xsl
----splashpage.xsl
--style
---css
----reset.css (reset all element in the browser)
----main.css (start from scratch)
----jquery
-----common.css (special jQuery ui stylesheets)
----resources (all resources (images) needed for the stylesheet)
-----*.jpg
-----*.gif
-----*.png

--------------------------------------------------------
Xhtml structure

-Doctype
<html>
<head>
<tilte>Always use a tiltle</title>
<meta>
<style>
<script>
</head>

<body>
<div id="main">
<!--
Only w3c valid xhml with no scripting within the elements/atrributes
(so no element-event based manipulation)
All the manipulation/interaction will hapen using a structed DOM in
combination with classes, unique id's, titles and names (Xpath
approach)
(thanks to jQuery)
-->
</div>
</body>
</head>
Reply all
Reply to author
Forward
0 new messages