Hot topics for both consumers and webmarketers on WebmasterRadio.FM
Every Wednesday, 5PM Eastern.
Web Application Development Tips
Properly Comment your code
My motto: "Code as if the person taking over my position is an insane killer" -- Meaning, if they can't understand what I did, they might come looking for me. ALSO, if you have to revisit a piece of code you wrote long ago, it helps to know what you did, and why. When you create a new function, add a comment block at the top. When you start a new webpage, add a comment block at the top. When you change a line of code somewhere in the page, either add a revision line at the top, referencing the changed code, or use an inline comment where you actually changed the code. For a good example of commenting code, see www.meridiandevelopmentsystems.com/lifetips/03.htm
Save Tip
Comments
Tip Rating
How are web applications structured?
Web applications are developed as three-tiered client-server applications that separate user interface, process logic and data administration. These tiers are maintained independently, allowing for flexibility in location, operating system and development languages.
Save Tip
Comments
Tip Rating
Using cookies
You can use cookies (local files) to store information instead of having to post variables back and forth between pages. It's easy - just use the request.cookies and response.cookies objects and methods. To save a value to a cookie, simply create a value, such as oranges: response.cookies("oranges") = 13 -- now you have a cookie on your computer with a key name of "oranges" which has a value 13. To retrieve the information, use the request.cookies method as: myVar = request.cookies("oranges") which will retrieve the value 13. You can also use the cookies as collections, such as response.cookies("oranges")("navels")=13. Now you have 13 Navel Oranges stored. To retrieve, use the same format: myVar = request.cookies("oranges")("navels").
Save Tip
Comments
Tip Rating
Properly Comment your code
My motto: "Code as if the person taking over my position is an insane killer" -- Meaning, if they can't understand what I did, they might come looking for me. ALSO, if you have to revisit a piece of code you wrote long ago, it helps to know what you did, and why. When you create a new function, add a comment block at the top. When you start a new webpage, add a comment block at the top. When you change a line of code somewhere in the page, either add a revision line at the top, referencing the changed code, or use an inline comment where you actually changed the code. For a good example of commenting code, see www.meridiandevelopmentsystems.com/lifetips/03.htm
Save Tip
Comments
Tip Rating
Stored Procedures
If you are using a database, try to use stored procedures instead of inline asp database code.
Stored Procedures are scripts that are run on, owned by, and specific to your database. They generally reside IN your database files. If you have ever looked at a very large asp file (I have seen rediculously large 2000+ line asp files - complete with functions, html, database calls, sql text, style information, etc.), and I will tell you it is not pretty, nor is it easy to change, maintain, edit, or even follow. If at all possible, don't have inline sql. If you can access the database, and use stored procedures, not only will it make the code easier to follow, but you'll never have to dig into the code again to make data changes - simply edit the stored procedure on the database, or the function call you create that calls the stored procedure. For a better example, see www.meridiandevelopmentsystems.com/lifetips/05.htm.
Save Tip
Comments
Tip Rating
Who uses web applications?
Actually, these days pretty much everyone uses some sort of web applications. If you use Gmail, you use a web application developed by Google called an e-mail client. There are endless opportunities for web application development. Consider that online stores, online auctions, wikis, discussion boards, weblogs, contact managers, photo sites and many of the other things you DO online all involve web applications.
Save Tip
Comments
Tip Rating
What are web applications?
Web applications are operating-system independent server-side programs accessed by the user over the internet through a web browser. Using web browsers as 'thin clients' web application developers do not require users to upgrade any software when enhancements are made to the system.
Save Tip
Comments
Tip Rating
How can I learn more about web application development?
One of the best ways to learn more about web application development is to attend a web application developer conference like Web Design World, in Boston. This conference is perfect for Boston Web development companies who are looking to learn more about the up and coming technology. Find one in your area, or save up and spend the bucks to go. It will certainly be worth it!
Save Tip
Comments
Tip Rating
Error handling in asp
When your code bombs and displays a "Page can't be reached" or and other error page, it's embarrasing. Here's a more elegant way to handle it. Use "On Error Resume Next" and "On Error Goto 0" EFFECTIVELY. First create an error page yourself - one that not only looks better than the standard error page, but that also tells the user something usable.. and include a "go back" button if necessary.
To use the above, write:
On Error Resume Next
...on the line ABOVE where the error would possibly happen, for instance, just before a database call.
Then on the line immediately after the offending line, write:
If err.number <> 0 then response.redirect "yourerrorpage.asp?err=" & err.description
*note: use this redirect ONLY if you want to alert the user of the error. You can omit this if you simply want the user to continue without an error showing up. You will have to find out why the error happened, but that's out of scope with this tip.
After that offending line, write:
On Error Goto 0
-- this resets the error object.
On your error page, at the top (but within the <% %> code block) write:
response.write "Error: " & request.querystring("err") & " please contact your administrator, or to try again, click here" (originalpage.asp is the page you had the error).
Microsoft has a good resource on this topic.
Save Tip
Comments
Tip Rating
Stored Procedures
If you are using a database, try to use stored procedures instead of inline asp database code.
Stored Procedures are scripts that are run on, owned by, and specific to your database. They generally reside IN your database files. If you have ever looked at a very large asp file (I have seen rediculously large 2000+ line asp files - complete with functions, html, database calls, sql text, style information, etc.), and I will tell you it is not pretty, nor is it easy to change, maintain, edit, or even follow. If at all possible, don't have inline sql. If you can access the database, and use stored procedures, not only will it make the code easier to follow, but you'll never have to dig into the code again to make data changes - simply edit the stored procedure on the database, or the function call you create that calls the stored procedure. For a better example, see www.meridiandevelopmentsystems.com/lifetips/05.htm.
Save Tip
Comments
Tip Rating
Using cookies
You can use cookies (local files) to store information instead of having to post variables back and forth between pages. It's easy - just use the request.cookies and response.cookies objects and methods. To save a value to a cookie, simply create a value, such as oranges: response.cookies("oranges") = 13 -- now you have a cookie on your computer with a key name of "oranges" which has a value 13. To retrieve the information, use the request.cookies method as: myVar = request.cookies("oranges") which will retrieve the value 13. You can also use the cookies as collections, such as response.cookies("oranges")("navels")=13. Now you have 13 Navel Oranges stored. To retrieve, use the same format: myVar = request.cookies("oranges")("navels").
Save Tip
Comments
Tip Rating
What is the future of application development?
Application Development will allow future creation of processes that increase the speed and flow of information across an enterprise, application, platform and skill set. Application development will deliver these through new applications designed for agility, and by evolving existing software for reuse.
Save Tip
Comments
Tip Rating
Error handling in asp
When your code bombs and displays a "Page can't be reached" or and other error page, it's embarrasing. Here's a more elegant way to handle it. Use "On Error Resume Next" and "On Error Goto 0" EFFECTIVELY. First create an error page yourself - one that not only looks better than the standard error page, but that also tells the user something usable.. and include a "go back" button if necessary.
To use the above, write:
On Error Resume Next
...on the line ABOVE where the error would possibly happen, for instance, just before a database call.
Then on the line immediately after the offending line, write:
If err.number <> 0 then response.redirect "yourerrorpage.asp?err=" & err.description
*note: use this redirect ONLY if you want to alert the user of the error. You can omit this if you simply want the user to continue without an error showing up. You will have to find out why the error happened, but that's out of scope with this tip.
After that offending line, write:
On Error Goto 0
-- this resets the error object.
On your error page, at the top (but within the <% %> code block) write:
response.write "Error: " & request.querystring("err") & " please contact your administrator, or to try again, click here" (originalpage.asp is the page you had the error).