cf.Objective

Speaking at cf.Objective

Recommended Books

Blog

My CF.Objective Schedule

I'm in Minneapolis! The weather is great, the hotel is killer, the gym lives up to my expectations, and the wifi has been pretty solid thus far. Looking forward to starting the CF.Objective conference, learning a ton, seeing friends, doing some networking, and generally running myself ragged for the next few days. (I'm staying an extra day to visit with friends and check out a few local music things.)

Here's my weak attempt at trying to schedule the next few days...they're are so many good presentations, it's really hard to pick:

Wednesday night:
Reception

Thursday-day:

The TDD List
Maintaining Healthy ColdFusion Servers
Online Payments Made Easy(er)...though I might swap that for Enterprise JavaScript Applications
How Mura CMS will save CFML (and you can too)
Putting it All Together - Building Applications with HTML/JavaScript/CSS

Thursday night:

The website just says "Community Events"...that sounds incredibly suspicious...I'm in!
Lightning Talk Extravaganza (again very suspicious...I'm in!)
CF Hour live broadcast

Friday-day:

Getting closure on Closures
Ten Steps to Move your Use of Caching Beyond The Basics....though I may swap that for Application Security: Myth or Fact
Building HTML5 games with PhoneGap, JavaScript and CSS3
Getting Started with Mobile Development
How to Pimp Out Your Model
Slatwall: An Open Source ColdFusion eCommerce Platform

Friday night:

Runtime Expectations broadcast / dinner
Evening session...either The Importance of a Modular CMS or CFML Frameworks
Evening session 2...too many choices! My head may explode trying to pick one!

Saturday:

Prepping Now for an HTML RIA Future
Authentication Made Easy Using Twitter, Facebook, Google, and more
PhoneGap: Yeah it's that easy...
Creating Enterprise Dashboards with ColdFusion...or maybe Bootstrap: A developers best friend
Intro to Model View Controllers (Without a Framework)
Closing Remarks

I'll do my best to post notes about the presentations, though with so much going on that may not get completed for a few days...

-Nolan

CF.Objective and CF Hour Podcast

Whew! Things are finally starting to return to normal for me around here! Schedules and resources have been rather crazy lately, to say the least! And among other side-effects of that, I haven't been blogging much lately. In an effort to quickly fix that...

I was interviewed for the latest episode of the CF Hour Podcast, along with Denard Springle, Mark Mandel, and Ryan Anklam. We all talked about the presentations will be giving at CF.Objective later this week...though somehow the conversation turned to beer...I'll have to figure out how that happened.

My preso is "Intro to Model View Controllers Without a Framework". If you haven't registered yet, you still have a day or so to reserve a space and attend the conference!

I'll do my best to blog various bits of the conference, though I hear the gym in this hotel is pretty amazing. If I don't respond to email for the next few days, check the gym. I'll be the guy playing air-guitar while he's on the treadmill.

-nolan

Tuesday at SACCFUG - Intro to FW/1

Tuesday at the Sacramento ColdFusion User Group, I'll be giving an introduction to the FW/1 framework. We'll also have some new t-shirts to give away and we'll do our annual SOFTWARE RAFFLE too! Must be present to win! More details at www.saccfug.org. See you there!

-nolan

Naming conventions for database columns

Earlier I was listening to the CFHour Podcast #124 (by the way, this is a great show for anyone wanting to keep up on the ColdFusion community). This particular episode discussed (among other things) databases and naming conventions for columns. The main point that was brought up was prefixing columns with the table name, and when developers should/shouldn't do this. The example given (which is probably the most common scenario) was the primary key "ID" column -- i.e. naming the column "TableNameID", rather than just "ID". The discussion of "why/when to do this?" went back and forth, and it pretty much boiled down to a few things:

1. Personal preference on naming columns -- some people use "ID", some use "TableNameID".
2. It adds to the readability of the code. But WHY? In a complex query, you're probably aliasing the tables anyway, so you'd end up with "TableAlias.ID", which is just as readable (assuming you use an appropriate name for your table alias).
3. It's redundant. If I'm in the Users table, I know that "ID" is referring to the ID of a User.
4. But what about, say, in a CFLoop? If the code contains "#ID#", it's not clear which table ID is being looped over (which is true...but really the problem in this case is, the developer was lazy and didn't scope the variable -- "queryName.ID" being much more readable than "ID").

Personally (unless there is some other shop standard to which I must adhere), I use "TableNamePK" for my primary keys, and "TableNameFK" for my foreign keys. Here's why:

I've run into several projects where (because of business requirements), I'll have tables that look something like so:

tblManufacturing --
ManufacturingID
Name
VendorID
PartnerID
OrderModuleID

Let's say that VendorID, PartnerID are NOT foreign keys to other tables (but OrderModuleID is), they are just columns that meet a business requirement (maybe this is data that's entered manually by an employee). Maybe "VendorID" is an industry standard term for that piece of data, predating our application by years or even decades.

If I rename "VendorID" and "ParnterID" to avoid this confusion (which is only confusing to me, the developer, as the business units will never see the primary keys), it would have slowed down communication among the team members ("when you say VendorID, you actually mean the column I've renamed to VendorAccessCode", etc). So we can't really rename these "ID" columns that are based on business rules, but since the business folks don't really care about the primary key column, we can use a different naming convention for that, without slowing down anyone.

Looking at it from the other side, which "ID columns" represent foreign keys to other tables? Which columns should have constraints applied to them? By just looking at this table, I have no way of answering that. This could slow down development, causing developers and DBAs to go looking for foreign key relationships that don't exist.

But what if the table were named like so:

tblManufacturing --
ManufacturingPK
Name
VendorID
PartnerID
OrderModuleFK

Now, by just looking, which column is the Primary Key? And which ones are Foreign Keys to other tables? And which ones store some sort of 'ID' that is part of a business rule, but isn't actually a foreign key? By using "PK" and "FK", it's much more clear which types of data are stored in the columns, and I've typed the exact same number of characters...so nobody is allowed to complain about this being too much typing. ;)

Whichever convention you pick, you should stick to it consistently throughout the application (unless you have a really good reason for breaking it). I've had to write complex recursive algorithms before that traversed down a hierarchial database of roughly 500 tables, and needed to be able to "predict" the name of the next primary key in the tree. Because I used the same naming convention for every table in the database, the algorithm worked throughout the entire system. If there was no rhyme or reason to how things were named, I would have had to provide some sort of "map", listing each table and its primary key column (yet another thing to maintain, as well as a possible point of failure in the application). Additionally, I was able to write regex patterns to find foreign keys, by searching for any column name ending with "FK", which also wouldn't have worked if I'd stuck with the "ID" convention for everything.

-nolan

Adding Meta Data to an Entire Site in Mura

This is mostly for my own reference...isn't that how most blog posts start these days? :)

As some of you know, when I'm not busy with consulting, I play music in a variety of projects. Earlier I needed to update the meta "keywords" and "description" for my band's website (currently running Mura 5.5) -- the meta data is the same for every page across the site, so I was looking for one site-wide place where I can make such a change. My first thought was "there's probably a site-wide setting for that in the Mura Admin", but after poking around for a few minutes, that didn't seem to be the case. I suppose it's possible that the meta data is hard-coded into the site theme (though unlikely), so let's check there. Mura has a site-specific directory where it stores the themes, like so:

/[sitename]/includes/themes/[theme name]

...and underneath there, you'll find a variety of files composing that theme (css, images, some CF templates for headers/footers, etc). Among these is html_head.cfm which contains all the things you'd typically find in the section of a website, and in there we find:

<meta name="description" content="#HTMLEditFormat($.getMetaDesc())#" />
<meta name="keywords" content="#HTMLEditFormat($.getMetaKeywords())#" />

....Okay, so the meta data isn't hard-coded, and there isn't a site-wide setting for it either. After a bit more searching, I found this link discussing "converting a third-party theme to a Mura theme" (not the most obvious of places for info about meta data, but hey it contains the answers I needed). About halfway down the page is this blurb:

Notes: Unless you specify otherwise on a specific page, Meta data content cascades down to the content nodes below. This means you don't have to set the meta data content on every page unless you specifically want to.

So let's to back to Mura Site Manager...my site content is laid out like so:

Mura Site Manger screenshot

As you can see, everything is below "Home", so let's click on "Home", then go to "Meta Data" and add the new keywords and description.

Success! So although the answer I needed was listed as part of "converting third-party themes", the answer applies to pretty much any theme in Mura, regardless of where it came from. As long as the theme html_head.cfm file includes these lines:

<meta name="description" content="#HTMLEditFormat($.getMetaDesc())#" />
<meta name="keywords" content="#HTMLEditFormat($.getMetaKeywords())#" />...this should work just fine.

-Nolan

More Entries

Search

Recent Comments

Naming conventions for database columns
Leeward said: Naming conventions and organization of fields and tables are... [More]

Naming conventions for database columns
Nolan Erck said: @Eden -- I should clarify that part of my post. I don't &quo... [More]

Naming conventions for database columns
Steve W said: I guess I have never had that situation, but I would attempt... [More]

Naming conventions for database columns
Leeward said: Naming conventions and organization of fields and tables are... [More]

Naming conventions for database columns
Nolan Erck said: @Eden -- I should clarify that part of my post. I don't &quo... [More]

Naming conventions for database columns
Steve W said: I guess I have never had that situation, but I would attempt... [More]



BlogCFC was created by Raymond Camden. This blog is running version 5.9.7. Contact Blog Owner