Skin Spider : Applying The Programmatic Configuration Object

Posted October 30, 2006 at 9:15 AM by Ben Nadel

Tags: ColdFusion, Skin Spider

To learn all about Skin Spider, click here.

To view the most updated application, click here.

To view the current code base, click here.

In my earlier updates, I created two ColdFusion component configuration objects, Config.cfc and PublicConfig.cfc. After some discussion on the blog, I have decided to go with the private Config.cfc. I am not crazy about having to make method calls to access things that I feel will not change very often. But, the method interface does allow for more flexibility and provides better protection from variance (PV). By hiding the internal workings of the Config.cfc I will be able to change what is going on in the Config.cfc without the dependent code being affected.

Building the configuration object was one step, the next step was applying it. First, I removed all inline config code from the Application.cfc ColdFusion component. Now, all config code should be in the Config.cfc ColdFusion component. As I was doing this, I realized that the Max Data Storage variable and the path to the data storage files should be moved to the Config.cfc as well as the rest of the config items. To accomodate this, I added the appropriate config variables as well as the "getter" methods for these values.

Then, I went through all the code and took out all references to the ColdFusion method, ExpandPath(). These paths, as well as all relative web paths (related to videos and images) were replaced with calls to the config object (ex. APPLICATION.Config.GetFullPaths().Videos). I did this in the following files:

delete_video.cfm
edit_video.cfm
favorites.cfm
home.cfm
search.cfm
spider.cfm
spider_gallery.cfm
spider_gallery_links.cfm
spider_video.cfm

As I was going through the code doing this, I realized that there was another item that I could move into the config object: the path to application executables. Remember, when we grab the links off of a thumbnail gallery page, we are taking a screen shot of the web page itself (spider_gallery.cfm). To do this, we are executing WebShotCMD via the ColdFusion CFExecute tag. In this application all executable are stored in "extensions/executables/" and this seemed like a good path to keep in the Config.cfc object. I added this path to both the relative and full paths within the Config.cfc configuration object.

That fact that as I was applying the programmable config object I found three more config items just goes to show that we are going to keep discovering ways to improve the system as we go. There is nothing wrong with having a good design up front. But, you never want to get sucked into "Analysis Paralysis" where you never move forward because you can't settle on a good design. Start off with a good base design, then just start coding. When you find a place to improve the code, improve it, but the important thing is just to get a move on.

As I was looking at the HTML that was being output after I applied the Config.cfc methodology, I realized that all the web paths were messed up. In the Config.cfc, the relative paths were "server" paths due to the CleanServerPath() method calls. The problem with that is that the slashes are different for web and server and I was using these "server" paths to build web links. To remedy this, I have made all the relative paths in the Config.cfc "web" paths by passing them through the CleanWebPath() function. I figure only the web paths will ever use these relative paths and, it won't affect the full paths as those are getting passed through the CleanServerPath() function anyway.



Reader Comments

Oct 31, 2006 at 7:49 AM // reply »
48 Comments

Ben,

I hav been using request variables for my configuration information (set in a settings.cfm file), but I really like this approach. I may borrow it in future projects.

Your database schema XML looks almost exactly like the XML used to define a database schema for DataMgr. The only differences are that I use a "field" tag instead of a "column" tag (it would be very easy for me to make it accept either) and instead of a "type" attribute with the database datatype, I have a "CF_DataType" attribute with a value from the "cfsqltype" from the "cfqueryparam" tag. In retrospect, I wish that was what I had named my attribute.

I think the DataMgr approach could really fit what you are doing here (of course, I am biased ;)


Nov 17, 2006 at 3:49 PM // reply »
1 Comments

I note that this is progressing nicely and REALLY LOOKS like a finished app, plenty of functionality, and I've downloaded it as something to pick apart and learn from the pieces...
Add to things to think of doing, when editing a movie/record, say on the second page, that on submitting it always takes you back to the first page. Since you were so kind as to allow adding tags without having to go back and choose add tags every time, consider adding a url or form variable to indicate what page the user was on when they chose to edit, and return them to that page.
And if it was just a senior moment on my part, ignore (if you can't reproduce the same behavior)


Nov 17, 2006 at 9:57 PM // reply »
10,640 Comments

Jeff,

I am in agreement 100%. This is on the list of things to upgrade before I will consider Iteration 2 complete.

In order to do this, I am going to come up with a sort of interal bread crumbing system where each page is represented by a given URL. Then I will figure out how to send the user back to the more recent "referrer".

The tricky part is that with pages like a form where (due to data validation) I might have multiple submites to the same page, I have to come up with a way to not use the first form load as the referrer for the second form load.

Should be exciting as it probably the biggest thing left to do for iteration 2.

I am glad you liking the app-in-progress. Please feel free to make any and all suggestions. It's always appreciated.


Post A Comment

Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.

Please review the following issues:

Author Name:


Author Email:

Author Website:

Comment:

Supported HTML tags for formatting: <strong>bold</strong>   <em>italic</em>   <code>code</code>







  • Help Wanted - Find Your Next ColdFusion Job
InVision App - Prototyping Made Beautiful With Prototyping Tools Ben Nadel's Company - Epicenter Consulting Recent Blog Comments
Feb 10, 2012 at 7:21 PM
jQuery AJAX Strips Script Tags And Inserts Them After Parent-Most Elements
Update! Instead of $(eval(options.insertAfter)).after(data['insertData']); I now use: var ajaxNode = document.createElement('span'); var parent = $(eval(options.insertAfter))[0].parentNode; ... read »
Feb 10, 2012 at 6:18 PM
jQuery AJAX Strips Script Tags And Inserts Them After Parent-Most Elements
encountered this same, what I consider, jQuery bug last week. I'm building a site in which I load some content via AJAX. This content contains Linkedin share button placeholders which Linkedin API ne ... read »
Feb 10, 2012 at 11:30 AM
Cross-Origin Resource Sharing (CORS) AJAX Requests Between jQuery And Node.js
After you understand the concepts here, this is an awesome cheatsheet for enabling CORS in just about anything http://enable-cors.org/ ... read »
JM
Feb 10, 2012 at 9:10 AM
My Safari Browser SQLite Database Hello World Example
@Amy, Here is a very good tutorial on how to use JOIN: http://www.sqltutorial.org/sqljoin-innerjoin.aspx ... read »
Feb 10, 2012 at 4:42 AM
Building A Twitter-Inspired RESTful API Architecture In ColdFusion
This is great, very useful Ben. I spotted a small typo in the api.cgm listing: <cfthrow type="Unauthroized" /> Cheers Stefan ... read »
Feb 9, 2012 at 10:35 PM
CFDirectory Filtering Uses Pipe Character For Multiple Filters (Thanks Steve Withington)
I was wondering if there would be a filter you could apply so that you got everything but what you included in the filter. As in show me all docs that are not a .pdf. ... read »
Feb 9, 2012 at 10:29 PM
Learning ColdFusion 9: Application-Specific Data Sources
@Ben, No offence, but if people were really wanting advanced features they would be using a platform like ASP.NET MVC. CFML is so structurally compromised as a tag-based scripting language that ... read »
Feb 9, 2012 at 10:03 PM
Subversion - Cleanup Failed To Process The Following Paths
@Leviaguirre, do you still have problems with this? ... read »