Skip to content

Instantly share code, notes, and snippets.

@orangexception
Created October 13, 2011 13:25
Show Gist options
  • Save orangexception/1284209 to your computer and use it in GitHub Desktop.
Save orangexception/1284209 to your computer and use it in GitHub Desktop.
storeStructIntoSession
<cffunction name= "storeStructIntoSession"
output= "false"
hint= "I store a form into the session scope">
<cfargument name= "stTarget"
required= "true"
hint= "I am the target struct for storage." />
<cfargument name= "sSessionKey"
required= "false"
default= "#createUUID()#"
hint= "I am the session key for the struct." />
<cfargument name= "bIgnoreEmptyFields"
required= "false"
default= "false"
hint= "I am a toggle that will ignore empty keys." />
<cfargument name= "lsKeysToIgnore"
required= "false"
default= ""
hint= "I am a list of struct keys to ignore." />
<cfset var stCopy= duplicate( stTarget ) />
<cfset var sKey= "" />
<cfloop collection= "#stCopy#"
item= "sKey">
<cfif listFindNoCase( lsKeysToIgnore , sKey )
or ( bIgnoreEmptyFields and len( stCopy[ sKey ] ) eq 0 )>
<cfset StructDelete( stCopy , sKey ) />
</cfif>
</cfloop>
<cflock scope= "session"
type= "exclusive"
timeout= "15">
<cfset session[ sSessionKey ]= stCopy />
</cflock>
<cfreturn sSessionKey />
</cffunction>
<!--- Store Form scope into session.plansearch --->
<cfif structKeyExists( form , "fieldnames" )>
<cfset storeStructIntoSession( stTarget= form ,
sSessionKey= "plansearch" ,
bIgnoreEmptyFields= true ,
lsKeysToIgnore= "fieldnames,submit" ) />
</cfif>
@orangexception
Copy link
Author

I get where you're coming from. I've run a similar spacing setup before.

Like you, I have my own reasons for doing what I do. I use multiple machines and IDEs and this coding style displays fine in each. Github decided to change the tab default to 8 spaces, which is wonky no matter how you look at it.

My coding style is constantly evolving. I change my style when I find a better way, either through experimentation or reviewing code. If I think my way is better than the team standard, then I'll attempt to show them why and update the standard.

If the team standard was different from the default of 4 spaces for 1 tab, then I would adapt to fit for team code.

I figure if a team member wants to change the style, then they're welcome to do so. Some IDEs allow you to change formatting in a button press. Otherwise, you can do a simple find and replacements to change the spacing. The whole process shouldn't take more than a few minutes. (I have some replacement scripts if you're interested.) If you're coding differently from the team standard, then you get to live with the consequences of your choice.

I'll probably do a whole post on my coding style, but that's the gist of it (couldn't resist).

@jeffcoughlin
Copy link

jeffcoughlin commented Nov 14, 2011 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment