Skip to content

Instantly share code, notes, and snippets.

@bennadel
Created March 24, 2014 23:51
Show Gist options
  • Save bennadel/9751978 to your computer and use it in GitHub Desktop.
Save bennadel/9751978 to your computer and use it in GitHub Desktop.
My Coding Methodology - Understanding The Madness And The Man Behind It
SELECT
u.first_name,
u.last_name,
u.email
FROM
user u
INNER JOIN
user_type t
ON
u.user_type_id = t.id
WHERE
u.is_active = 1
AND
ISNULL(
(
SELECT
MAX(foo)
FROM
bar
),
0
) > 0
AND
u.id IN
(
SELECT
id
FROM
cool_user
)
AND
(
u.is_super_user = 1
OR
u.is_ghosting = 1
OR
ISNULL(
u.user_type_id,
0
) = 14
)
<cfif Len( strText )>
<cfif (Len( strText ) GT 0) />
<cfif (
qUser.RecordCount AND
Len( qUser.ssn ) AND
(qUser.date_started LTE Now())
)>
<!--- Code. --->
</cfif>
<!---
This is a really long comment here. It demonstrates the need to have
the comment broken up into multiple lines and then indented. Isn't
that just peachy.
--->
// This is a really long comment here. It demonstrates the need to have
// the comment broken up into multiple lines within the cfscript block.
// Isn't that just peachy.
</ul><p></p></div><p>All included templates (NOT top-level url-accessible templates) should have the following comments at the top of the file to document the file use and update history:</p><div class="codefixed"><ul><!--- ---------------------------------------------------------------- ----
File: methodology.txt
Author: Ben Nadel
Section: N/A
Desc: This file provides a methodology for consistent and
successful application development in ColdFusion.
Upate History:
11/15/2005 - Ben Nadel
Requested By Ben Nadel
I have update this document to add more conventions
for CFC coding.
11/14/2005 - Ben Nadel
I just started this document.
----- ------------------------------------------------------------//// --->
<!--- ---------------------------------------------------------------- ----
File: securepage.cfm
Author: Ben Nadel
Desc: This tag allows a page to be given a login without
integrating it with the security of the application itself.
This is good for single pages or mini-extranets that the
client wants to post to.
Sample Code:
<!-- Import tag library. -->
<cfimport taglib="../lib/" prefix="sys" />
<!-- Secure page. -->
<sys:securepage username="ben" password="test">
.... Code to be secured goes here ....
</sys:securepage>
Update History:
11/16/2005 - Ben Nadel
Added piggyback functionality to allow one secure
page to use the login status of another template.
11/14/2005 - Ben Nadel
Beta tag has been completed.
----- ------------------------------------------------------------//// --->
<!--- ---------------------------------------------------------------- ----
File: FormErrors.cfc
Author: Ben Nadel
Desc: This component handles a form errors queue used when
validating data send through a form submissions. Is is
essentially a non-persisting message queue with a standard
message queue interface.
Sample Code:
<!-- Create the CFC. -->
<cfset FormErrors = CreateCFC("FormErrors").Init() />
<!-- Check a field. -->
<cfif NOT Len(FORM.first_name)>
<!-- Add an error message. -->
<cfset FormErrors.Add("Please enter a first name") />
</cfif>
<!-- Check for form errors. -->
<cfif NOT FormErrors.Length()>
....
</cfif>
Update History:
11/14/2005 - Ben Nadel
Form Errors has been completed.
----- ------------------------------------------------------------//// --->
<!--- ASSERT: intUserID contains newly created or existing user id. --->
<!--- TODO: Add error checking for out-of-range values. --->
<!--- TODO: BUG: Crashes for negative numbers. --->
INSERT INTO user
(
first_name,
last_name
)
VALUES
(
<cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#FORM.first_name#" />,
<cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#FORM.last_name#" />
)
<!---
NOTE: Jennifer Shutes asked for this to be disabled on October 15,
2005. It might be put back in later.
--->
<!---
.... Commented out code goes here ....
--->
<!--- File comment (see above sections) --->
<cfcomponent
displayname="MyCo"
extends="BaseComponent"
output="false"
hint="MyCo does something">
<cffunction name="Init" access="public" returntype="MyCo" output="false"
hint="Returns an initialized MyCo instance.">
<!--- Define arguments. --->
<cfargument name="DSN" type="struct" required="true" />
<cfscript>
...
// Return THIS object.
return( THIS );
</cfscript>
</cffunction>
</cfcomponent>
UPDATE
user
SET
first_name = <cfqueryparam value="#..#" cfsqltype="CF_SQL_VARCHAR" />,
last_name = <cfqueryparam value="#..#" cfsqltype="CF_SQL_VARCHAR" />
WHERE
id = <cfqueryparam value="#..#" cfsqltype="CF_SQL_INTEGER" />
UPDATE
user
SET
foo = <cfqueryparam value="#..#" cfsqltype="CF_SQL_BIT" />
WHERE
is_active = 1
<cfmail
to="...."
from="...."
subject="Hey, this is a really cool methodology document"
cc="..."
bcc="..."
wraptext="72"
type="HTML">
...
</cfmail>
<table>
<tbody>
<!--- Loop over the data rows. --->
<cfloop query="qRows">
<tr>
<td>
<cfset WriteOutput( qRows.data ) /><br />
</td>
</tr>
</cfloop>
</tbody>
</table>
<cfset Foo( Arg1, Arg2 ) />
<cfset intX = (intY + 2)
<cfset intX = ( intY + 2 ) />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment