Iteration 2 : The Code
The Code Viewer
My journey into Object Oriented Programming (OOP) and ColdFusion is well under way. We have completed Iteration One which was a shot-gun approach to web application development. This iteration is about refactoring and getting the application to work in a cleaner, more efficient way. There will be touches of OOP, but this is more about making the application better now that we have a good sense of usability issues and what we actually want it to do.
As always, this code viewer allows you to look at my progress on this project on a day-by-day basis. See how I am updating individual files. See where new methodologies are getting applied. See how OOP can help you.
Note: The code viewer works better in FireFox (big suprise), but is functional in both FireFox and IE.
The Application
For every code update, I will update the live application. The live application will always have the most recently updated code. Click here to launch the latest version of the application.
Iteration 2 : Code Updates
Download the updated code (ZIP file)
Just a minor update here. I have updated the videorating.cfm ColdFusion custom tag to have a toggle for whether or not the video clip is a favorite of the user. It works pretty much the same way as the rating (1 to 10) in that it uses a Javascript Image SRC attribute to call the application's API. I have included this as part of the videorating.cfm ColdFusion custom tag because it's sort of a rating and because the tag already existed; however, I could just have easily made a separate custom tag to do just the "favorite" functionality.
If you look at the search.cfm and the favorites.cfm ColdFusion templates, you will see that the only modifications that I have made are that I now get "is_favorite" from the database and use the "isfavorite" attribute of the ColdFusion custom tag. Everything else on those pages remains the same. This is the beauty of the custom tag - it helps protect or minimize the damage that variation can have on the system.
The two major changes of this update were made to the api.cfm ColdFusion template (our system API) and to the videorating.cfm ColdFusion custom tag. If you look at api.cfm, you will see that I have added another CFCase statement for the action "set_favorite". Like the "rate_video" action, "set_favorite" also takes the ID of the video in question. It also takes a boolean indicating whether or not the video is a favorite. It then takes this information and updates the database.
If you look at the videorating.cfm ColdFusion custom tag, you will see that I just added another link that says "Favorite." This link calls the Javascript method SetVideoFavorite(). This Javascript method is defined in the custom.js file. Like I said before, this method just uses the SRC attribute of a Javascript image to ping the system's API (api.cfm). In addition to pinging the API, this method also changes the CSS class of the Favorite link. If you try out the page, you will see that this CSS class defines the format and the gold star (background-image) of the link. Not very complicated stuff here. I have decided to make the gold start part of the CSS class, rather than an inline image because this way does not require the ColdFusion custom tag to know anything about the paths to the images folder. Right now, all the ColdFusion custom tag has to know about is what attributes it gets and what Javascript methods are available. I am trying to keep the coupling as low as possible.
So now, there is an inline way to rate the video clips and flag them as favorites. I have been trying to take care of these "low hanging" fruits - the easy changes - before I move on to the final, more complicated changes of Iteration 2. Hopefully over the holidays, I will have time to start thinking about the referential navigation, the biggest of the remaining Iteration 2 changes.
Reader Comments
There are no comments posted for this web log entry.
Iteration Two Updates
Nov 30, 06 Code Update
Nov 21, 06 Code Update
Nov 20, 06 Code Update
Nov 15, 06 Code Update
Nov 14, 06 Code Update
Nov 10, 06 Code Update
Nov 9, 06 Code Update
Nov 6, 06 Code Update
Nov 5, 06 Code Update
Nov 2, 06 Code Update
Oct 31, 06 Code Update
Oct 30, 06 Code Update
Oct 27, 06 Code Update
Oct 25, 06 Code Update
Oct 23, 06 Code Update



