Something Is Coming...

Something Is Coming Soon (banner)

CFMX7 and Apache 2.2.4

So, in my infinite wisdom, and much to the dismay of my wife, I decided to replace my server with a new (used) one. A slightly more powerful machine that a friend of mine was going to put on FreeCycle (Thanks Patti!), I thought it was perfect to go ahead and make some changes to my dev environment. I want to begin using Subversion, plus I figured I would go ahead and switch to CF on top of Apache (since IIS Sucks!), not to mention setting up CF on the multiserver install. Hey, why not.

Stephen Collins has a fine document called the ACME guide (for the uninitiated) that thoroughly covers setting up a basic, free development environment: Apache, ColdFusion, MySQL, (CF)Eclipse. I thought this would be a good place to start, but didn't realize that Apache had upgraded their server before AcidLabs could update the ACME guide. Whoops! ColdFusion install completes but Apache won't restart!

[More]

Variables and Naming Conventions

At work I (with heavy input from the rest of the team) am writing these guidelines for our development practices, so that everyone is working 'on the same page.' I will share this series here for others who may want to know how some folks do it.

Variables. They define the data within our applications. Hard to peg down within our system, with thousands of variables over thousands of files. For this reason, it is time to define proper variable declaration.

Variable naming conventions and scoping can be very different in different programming languages. Within ColdFusion variables are case insensitive, whereas in most others proper case is critical. With the wide mix of languages used here (XHTML, CSS, ActionScript, JavaScript, etc.) we will take the stance that all variables, across all platforms, should remain case specific unless explicitly necessary to change. A camel case approach should be used, with the first letter of the first word (or one word) of a variable remaining lower case, while any subsequent word is capitalized. i.e.: oneVariable, anotherVariable, stillAnotherVariable. (Functions should capitalize each word) You may also employ Hungarian Notation to further identify the type of a variable, if you wish, but it won't (at this time) be required.

Another important action with variables is declaring, and referencing them, from their proper scope. In ColdFusion, you could reference most variables without identifying the scope, but to do so would cause unnecessary load on our systems. When a template is processed by ColdFusion, if the scope is not identified then the server will search through each scope separately until the variable is found. Not only does this cause the system to overwork, but you also run the risk of the system discovering a variable of the same name within a higher scope of the search tree. By expressly referencing all variables by their scope you eliminate these possible issues within our system. Also (within ColdFusion) all scope names should be listed in all uppercase. i.e.: FORM.strUserName, SESSION.intUserID, URL.intStartRow.

Flash

Although they've been used in the past, _global and _root scopes should only be used cautiously. As we integrate more of our tools into each other, these scopes can easily cause problems. Local Variables should be used in functions when possible.

Adobe has a detailed document on best practices on using scope in ActionScript.

Use variable/instance names that describe the functionality of the the item being named. Append an underscore then the ActionScript abbreviation for the type or variable or instance when appropriate. This will make code hinting available in the Flash IDE. For example, next_btn, or submitForm_lv

Use anonymous functions when appropriate, so as not to clutter the code with named trivial functions. Example:

view plain print about
1/*Not this way:*/
2function nextButtonPress(){
3 timeline.nextFrame();
4}
5next_btn.onRelease = nextButtonPress;
6
7/*Rather, this way:*/
8next_btn.onRelease = function(){
9 timeline.nextFrame();
10}

Database Architecture

Table Names

Table names should be camel case, but with the first letter capitalized as well. Table names should not be the pluralized form of what it stores. Example: ProductItemDetail

Linking or Lookup tables which serve as a relationship between a Many-to-Many should include the word Map in the name, preferrably at the end. Example: ProductItemCategoryMap

Column Data Types

  • boolean: Boolean values are stored in bit columns, and have historically been named bVerbWhatever, for example bIsCertified.
  • foreign keys: Foreign key column names should be fkTableName, for example fkProductItemDetail.
  • hex color: Hexadecimal colors are stored in char(6) fields.
  • All fields that store numeric data should be of datatype INT(4) except for very special circumstances.

SQL

SQL keywords should appear in ALL CAPS. Tables should be aliased. For example:

view plain print about
1SELECT        PID.displayName,
2                        PID.description
3FROM            ProductItemDetail PID WITH (NOLOCK)
4WHERE        PID.ID = #arguments.itemDetailID#

All Joins should be specified in the FROM clause. For Example:

view plain print about
1SELECT PI.Make, PICM.Price
2FROM ProductItem PI WITH(NOLOCK)
3INNER JOIN ProductItemCategoryMap PICM WITH(NOLOCK) ON PI.fkItem= PICM.fkItem

There are, always, exceptions to the rules. Typically these exceptions are due to the rules of another language. For instance, within XHTML all tag names, attributes, and attribute values are always lower case. The exception to that rule is anything calling a script function (like the event actions) where case is defined by the JavaScript itself (which is case sensative).

Examples:

view plain print about
1<!--- ColdFusion variables --->
2<cfset VARIABLES.strNextPage = "myNextPage.cfm" />
3<cfparam name="URL.intRowStart" default="1" />
4
5<cffunction name="GetNextPage" access="public" output="false" returntype="string">
6    <cfreturn VARIABLES.strNextPage />
7</cffunction>
8
9/*Flash variables*/
10
11selectedElements = {};
12
13propCount = function(obj){
14    var count = 0;
15    for (var i in obj){
16        count++;
17    }
18    return count;
19}
20
21delete_btn.onRelease = function(){
22    if (propCount(selectedElements) == 0){
23        this._parent.error_mc._visible = true;
24    } else {
25        this._parent.error_mc._visible = false;
26        deleteElements(selectedElements);
27    }
28}

Comments

At work I (with heavy input from the rest of the team) am writing these guidelines for our development practices, so that everyone is working 'on the same page.' I will share this series here for others who may want to know how some folks do it.

First and foremost is documentation. We have an extremely large system, currently made up of nearly 7,000 ColdFusion, XML, Javascript, Cascading Style Sheet, ActionScript, and Flash templates. The original authors of these templates were spread fairly thin, working a variety of tasks while attempting to produce a usable product base to build our company upon. Because of this a large majority of our system is completely un-documented. Now, as a matter of standard practice, every template touched by a developer is given, at minimum, a document header comment to create some form of initial documentation.

[More]

Making The View: Part 7

OK, so let's get interesting. We've covered creating a base template in XHTML, properly divided our display declarations from our content by using Cascading Style Sheets, and pinpointed some areas within the base template which should be dynamic. Finally, in our previous tutorial, we brought all of this together in a reusable template, which we demonstrated by using it as a custom tag. Now we're going to really start having some fun, by redefining our view within some frameworks. Now, I'm no expert. There are probably a few dozen ways to properly handle the view within the different frameworks, so any other suggestions are welcome as always. We're going to start off with Model Glue:Unity, while I catch up on the changes to Mach II and Fusebox.

[More]

Internet Presence: Why Is It Pertinent?

OK, I've been busy. With the holidays, projects at work, and studying for my CF 7 Certification Exam, I am a little behind on my postings. So, I thought to do a little cross work posting here. This is the full, un-edited article which I wrote for the December edition of 'Dealer Marketing Monthly', a publication targeted to the automotive dealership industry (for which my employer develops and hosts websites). Editors, lovely people that they are, cut the article content in half and changed the tone entirely, prior to publication, so I give it to you here in it's totally un-edited splendor. May you gain some small nut of insight/knowledge/humor from reading my ramblings.

[More]

ColdFusion Mail Spool Lock

Recently I've seen posts on both the CF-Talk list at House of Fusion and the Adobe ColdFusion Forum about a lock on the CF Mail Spool. At some point messages in the spool recycle over and over, without processing out to the mail server or going in to the undelivered folder.

I was working for a small regional internet service provider when I began working as a ColdFusion developer. We hosted around six hundred corporate sites, most of which used the <cfmail> tag in some form of form processing or another. This was back in the days of ColdFusion 4.0, and was when I first encountered this issue, and I've seen it several times since.

Basically what happens is the ColdFusion server loses it's connection to the mail server momentarily. Typically you'll see an error in your ColdFusion mail.log file that will state that the connection to your mail server failed at some point. When this happens there is a file lock on a .cfmail file in the spool that was being processed at the time the failure occurred. The connection comes back, but the file lock seems to cause a continual loop on the spool, which disallows the flow of files from the spool to the mail server. It often goes unnoticed until a client calls in to complain that they haven't recieved any leads from their site.

The issue is really easy to get around, but does require you to take down ColdFusion services for a moment so that the file lock is released. Here is a general outline of what you should do.

  1. Stop ColdFusion services
  2. Cut and paste all .cfmail files from the spool folder into a temporary folder.
  3. Restart ColdFusion services
  4. Verify the mail server connection in the ColdFusion Administrator
  5. Drag .cfmail files from the temp folder back into the spool folder at about 200 messages at a time, waiting for all messages to process out of the spool before moving to the next batch.

That's it. Pretty easy to handle. Your greatest hurdle is convincing a shared hosting provider that this needs to be done, but if they watch the spool folder and notice the same messages re-enter the spool repeatedly, without dropping to the undelivered folder, then it is a solid indicator that this is what has occured. All files leave the spool and show up five, ten, even fifteen minutes later. I have now worked for two separate hosting companies running everything from ColdFusion 4 through 7, and have seen it occur on each version at one time or another. Hope this helps someone!

Field Of Stones

Many years ago, probably while stationed at NSA, I sat down and wrote this poem while coming up with content for the 741st MI BN's newsletter, for their Memorial Day edition. Since then it has also appeared in the Ocean View, DE American Legion newsletter, the Ocean City, MD Veterans of Foriegn Wars newsletter, and an abbreviated version on Poetry.com. I thought the content was still fitting for this Veteran's Day, a gentle reminder to thank all of my brothers and sisters-in-arms who put their lives on the line in the name of freedom.

[More]

Making The View: Part 6

There is more than one way to skin a cat. In our last tutorial I showed you an old, tried-but-true method for including page headers and footers. But, every ColdFusion developer knows that there are many different ways. In this tutorial we'll go over creating the same header and footer using custom tags.

Custom Tags provided a huge level of power to ColdFusion Markup Language, because it gave us the ability to write simple and elaborate code snippets that could be placed in a centralized repository for consistent reuse. One way to think of them is like an include, but with expanded functionality. Let's get started.

[More]

Welcome MXNA and Fullasagoog

I want to welcome new readers from MXNA and Fullasagoog. I hope that there is a little something here for everyone. You can read my Welcome post for a little more about what you might find here at Cutter's Crossing, and you can check out Who I Am for a little more information about me and what I might bring to the blogosphere. Again, welcome one and all, happy reading, and let me know what you think.

Previous Entries / More Entries