Quantcast
Channel: Add optional abort Attribute to cfinclude
Viewing all articles
Browse latest Browse all 40

Add optional abort Attribute to cfinclude

$
0
0

@dajester2013 wrote:

First of all, this falls into the category of something along the lines of:

function getUltimateAnswer(isCalculated) {
    if (!isCalculated) return "come back in 7 million years";
    return 42;
}

// vs

function getUltimateAnswer(isCalculated) {
    var result = "";
    if (!isCalculated) 
        result = "come back in 7 million years";
    else
        result = 42;

    return result;
}

I had a professor that would fail an assignment if there was a function with two return statements as in the first example. Now, I write code that does this on occasion, as it is quicker to implement. However, on a whole, I do strive to stick with the conditional logic with a single exit point.

Thats what I see is going on here. You may be doing maintenance on a some rather large and otherwise complicated templates, to where adding a else block around the remaining body of the template is not feasible. While sometimes necessary, using aborts as a normal way to end a request is, IMO, bad practice. It should be treated more like exit(1) for C programs. You should really only do it if there is a problem that you need to quit immediately before circuits get fried (well, maybe not that dramatic wink).

However, that does lead me to an interesting thought that I shall bring up as a new thread...

Read full topic


Viewing all articles
Browse latest Browse all 40

Trending Articles