Commenting Your Code - macromedia COLDFUSION MX 7 Web Application Construction Kit [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

macromedia COLDFUSION MX 7 Web Application Construction Kit [Electronic resources] - نسخه متنی

Ben Forta, Raymond Camden, Leon Chalnick, Angela Buraglia

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید











  • Commenting Your Code


    The last introductory topic I want to mention is commenting your code. Many books leave this to the very end, but I believe it is so important that I am introducing the concept right herebefore you start real coding.

    The code you have worked with thus far has been short, simple, and pretty self-explanatory. But as you start building bigger and more complex applications, your code will become more involved and more complex, and comments become vital. Here is why you should comment your code:

    • If you make code as self-descriptive as possible, when you revisit it at a later date you'll remember what you did, and why.

    • This is even truer if others have to work on your code. The more detailed and accurate comments are, the easier (and safer) it will be to make changes or corrections when necessary.

    • Commented code is much easier to debug than uncommented code.

    • Commented code tends to be better organized.


    And that's just the start of it.

    Listing 8.13 is a revised version of hello6.cfm; all that has changed is the inclusion of comments. And as you can see from Figure 8.17, this has no impact on generated output whatsoever.

    Listing 8.13. hello7.cfm


    <!---
    Name: hello7.cfm
    Author: Ben Forta (ben@forta.com)
    Description: Demonstrate use of comments
    Created: 12/1/2004
    --->
    &l275>
    <head>
    <title>Hello 7</title>
    </head>
    <body>
    <!--- Save name --->
    <cfset firstName="ben">
    <!--- Save converted versions of name --->
    <cfset upperFirstname=UCase(firstName)>
    <cfset lowerFirstname=LCase(firstName)>
    <cfset reverseFirstname=Reverse(firstName)>
    <!--- Save name length --->
    <cfset lenFirstName=Len(firstName)>
    <!--- Save repeated name --->
    <cfset repeatFirstName=RepeatString(firstName, 3)>
    <!--- Display output --->
    <cfoutput>
    Hello #FirstName#, and welcome to ColdFusion!<p>
    Your name in uppercase: #upperFirstName#<br>
    Your name in lowercase: #lowerFirstName#<br>
    Your name in reverse: #reverseFirstName#<br>
    Characters in your name: #lenFirstName#<br>
    Your name 3 times: #repeatFirstName#<br>
    </cfoutput>
    </body>
    </html>

    Figure 8.17. ColdFusion comments in your code are never sent to the client browser.


  • / 281