电脑爱好者,提供IT资讯信息及各类编程知识文章介绍,欢迎大家来本站学习电脑知识。 最近更新 | 联系我们 RSS订阅本站最新文章
电脑爱好者
站内搜索: 
当前位置:首页>> Asp>>The Real Basics of Functions in ASP:

The Real Basics of Functions in ASP

来源:www.aspfree.com | 2006-1-25 | (有2166人读过)

本站编辑安:昨天在国外的asp技术站看到一篇文章,感觉很好入门。由于时间原因没有翻译,大家可以看一下其中的代码部分。(Page 1 of 5 )

Re-usable code is a boon to developers. It's easy to manage, because it only needs to be written once; then, every time you want to do the same thing, you just call it up again. However, it does require a bit of thought and planning up front. John Puddinfoot walks us through several simple applications for re-usable code in ASP, focusing on functions.
As with every design decision, the choice to develop re-usable code is a matter of trade-off. Making the decision to develop re-usable code will help to produce more robust and maintainable solutions, but may require a little more time and thinking up front.

In many ways ASP is an unstructured language. The language itself does not constrain a developer to design something in a particular way, which again has its good points and its bad points. The emphasis is on the developer to apply hisr own style to the work. Functions provide developers with an option to produce code that can be used time and time again within a project and beyond, yet many ASP developers tend to shy away from using them extensively.

This article will introduce the basic concepts of functions within ASP, and we’ll go on to produce a very useful function to demonstrate the concept. To start us off, here's a very simple piece of work: doing some very basic maths to demonstrate that even with the simplest of coding tasks, functions have a real use.

Customer Spec: "Here’s the idea John, we have two values which we need to add together and display the result on the screen."

It’s a simple enough concept. We’ll take two numbers and add them together to create a result then display this to the screen. First we’ll do it the natural way. We’ll code it straight out – all two lines of code!

Without functions:

<%
result=2+2
response.write result & "<br />"
%>

Asp热门文章排行
网站赞助商
购买此位置

 

关于我们 | 网站地图 | 文档一览 | 友情链接| 联系我们

Copyright © 2003-2024 电脑爱好者 版权所有 备案号:鲁ICP备09059398号