Created
March 24, 2014 23:51
-
-
Save bennadel/9751978 to your computer and use it in GitHub Desktop.
My Coding Methodology - Understanding The Madness And The Man Behind It
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfif Len( strText )> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfif (Len( strText ) GT 0) /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfif ( | |
qUser.RecordCount AND | |
Len( qUser.ssn ) AND | |
(qUser.date_started LTE Now()) | |
)> | |
<!--- Code. ---> | |
</cfif> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- | |
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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. | |
----- ------------------------------------------------------------//// ---> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- ---------------------------------------------------------------- ---- | |
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. | |
----- ------------------------------------------------------------//// ---> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- ---------------------------------------------------------------- ---- | |
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. | |
----- ------------------------------------------------------------//// ---> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- ASSERT: intUserID contains newly created or existing user id. ---> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- TODO: Add error checking for out-of-range values. ---> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- TODO: BUG: Crashes for negative numbers. ---> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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#" /> | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- | |
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 .... | |
---> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE | |
user | |
SET | |
foo = <cfqueryparam value="#..#" cfsqltype="CF_SQL_BIT" /> | |
WHERE | |
is_active = 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfmail | |
to="...." | |
from="...." | |
subject="Hey, this is a really cool methodology document" | |
cc="..." | |
bcc="..." | |
wraptext="72" | |
type="HTML"> | |
... | |
</cfmail> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<table> | |
<tbody> | |
<!--- Loop over the data rows. ---> | |
<cfloop query="qRows"> | |
<tr> | |
<td> | |
<cfset WriteOutput( qRows.data ) /><br /> | |
</td> | |
</tr> | |
</cfloop> | |
</tbody> | |
</table> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfset Foo( Arg1, Arg2 ) /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfset intX = (intY + 2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfset intX = ( intY + 2 ) /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment