Why OO Rocks

It is late, I am really, really, tired but I am going to weigh in on this debate over whether OO is worth it or not. I offer this nugget of fun. I wrote a wrapper for the default CFC's created by Illudium a while back.

This is all the code I need to do the following database operations with only the contents of a struct (form in this case): INSERT, UPDATE, SELECT, DELETE, AND UPDATE a many to many look up table

<cfscript>
   databaseService.Update(MyTable, form);
   Select_ARTISTS = databaseService.Select(MyTable, form, orderby, "true");
   databaseService.insertinto(MyTable, form);
   databaseService.Delete(MyTable, form);
   databaseService.saveManyToMany("ORDERITEMS", MyFK, MyFKvalue, manyfield, manyValueList);
</cfscript>

// I even wrote a custom tag for it
<cf_query
   dbaction = "select/upsert/delete"
   table   ="sometable"   
   variables="#somestruct#"
   cflocation="#script_name#?event=action.#section#.#nav#" >


Mind you I am one of those "old skool" CFers that picked up OO in the last couple of years. So it can be done. It just takes some (hard) work, but no harder than learning CF to begin with... No really. It just takes time and deliberate practice and it will pay off. Just like anything else worth while.

Update: 7/20/2009 8:06:03 PM

I was asked about the wrapper for the Illudium CFC's and I will be releasing it later on this week

G OUT!!!

Seeking recommendations for a drop down menu (tabs)

I have a very finicky and non trivial CSS based layout that I have finally worked all the kinks out of. Actually it is only finicky in IE. Now the powers that be want to add drop down menus (tabs) the top nav bar that use the sliding door rounded corner technique.

I have tried a bunch of menuing systems: Dynamic Drive menus, Spry, some jQuery plugins, Massimo's hiermenu and a bunch of stuff I found off of the Google and all of them have problems of one sort or another. I can't position it correctly, it trows off other page elementsm the drop down columns are mis-aligned etc... forever and ever, world with out end. Amen.

I posted this to CF_talk a few months back (the site got shelved since then and it is back in production) and though I would hit up the blogosphere.. Has anybody out there had any luck with this and can recommend a tabbed menu dropdown solution?

The primary requirement are:

  • It can have sub menus
  • W3C XHTML compliant.
  • Allows for text based links

These are the Menus that I have tried so far:

(ot)

Pleas leave a comment below. Many TIA!!!

The best part about FOSS (Free and Open Source Software) is not that it is free.

I used to look at FOSS as a means to get free software: MySQL, Apache, Eclipse etc... FOSS is part of my day to day affairs and I dare say the best thing to ever happen to software and software developers.

But for me, FOSS is the best programming howto guide there is. It is like a living text book that is always getting better. I have learned more from reading other peoples source code than I have from any book, blog post or article. Being an autodidact, reading source code makes much sense than reading the English words used to describe the programming concepts.

Just this week I was asked to R&D a bunch of stuff and I found solutions for all the CF stuff by going to either CFLib.org or RIAForge.org. (Mad props to Ray Camden for making those sites. You saved my ass twice this week dude! Rock On with your bad ass self!)

Those sites are gold mines for CF programming knowledge. I have been turned on to so many new ideas and concepts by the folks that have shared their work that I want to give a shout out and thank you to y'all.

Thank you!!



A Quick and Dirty CSS Viewer.

When I work on a site with CSS that I am not familiar with I find this little widget to be very handy. I simply took Shlomy Gantz's viewCSS() function from CFLib.org and pointed it to my CSS files and voila I have a visual representation of all the CSS styles for the included style sheets. It is far from perfect and works best with text related CSS but the only real problem so far is that it tends to barf on /* CSS comments*/. But that is a pretty minor issue. Here is a zip file with the code.

Here are the Styles for this site

The code is ridiculously simple

<cfscript>
function viewCSS(cssCode) {
   var i ="";
   var cssItem="";
   var ret="";
   for(i=1;i lte listlen(arguments.cssCode,'}');i=i+1) {
      cssItem = listgetAt(arguments.cssCode,i,'}');
      if(findNocase('{',cssItem)) ret = ret & '<div style="#trim(mid(cssItem,findNocase("{",cssItem)+1,len(cssItem)))#">#trim(mid(cssItem,1,findNocase("{",cssItem)-1))#</div><br>';
   }
   return ret;
}
</cfscript>




<!--- Include any CSS files you want to view --->
<cfsavecontent variable="cssTxt">
<cfinclude template="stylel_ie.css">
<cfinclude template="style.css">
<cfinclude template="form.css">
</cfsavecontent>
<cfoutput>#viewCSS(cssTxt)#</cfoutput>

A Paradigm shift (Or how to learn OOP on the job with out screwing up).

I have been banging my head against CFOOP for about a year or two and thought I would share some of my tricks, trials and tribulations.

I just noticed how my thinking has changed when developing apps these days.

Huh... Thinking about thinking is meta-cognition. So what do you call thinking about what you are thinking about when thinking about metadata? I smell a cognitive infinite recursive loop in the making. (Note to self.. Tell brain to STFU for a minute so I can finish this blog entry FFS)

Anyways...

1. I write the procedural code to get the things I need done. I don't even think about OO at this point.

2. I turn everything into functions and try to atomize things as much as I can (where it makes sense to at least).

3. Then I create a CFC (or CFCs) to organise my functions

4. Then I rewrite my procedural code to incorporate my cfcs/functions

5. I turn THAT code into another function or set of functions

6. And then I turn THAT set of functions into another CFC (0ne ring to rule them all). IIRC this is your service layer.

I got into this whole head set from reading Head First Object-Oriented Analysis and Design.

Taking on this approach has really helped me a lot. When you are getting into a new discipline /paradigm shift /cognitive restructuring such as OOP it can be *VERY* overwhelming and it is *all too easy* to think yourself utterly stupid to the point where you are a quivering blob of "WTF?" before you even write your first line of code. So much so that you say fark it and go back to writing code like you used to (not good).

I have seen it time and time again both in my personal life and from reading interblargs.

What I find with this iterative, incremental approach is that if you get into time crunch, or think yourself stupid, or get in over your head, or get stuck, you can always bail out and still have a functioning app that you can go back to and clean up at a later date.

This approach has really allowed me to push my limits when I can (Read: on the clock) and bail out when I have/need to. And after a while you just start to think differently about code and writing OO code becomes a natural part of your daily affairs. I find myself looking at legacy code and thinking "What can I abstract into a function" or "How can I clean this heaping pile of spaghetti into something more useable". And the next thing you know you are seeing everything in those terms. Your thinking has changed.

The end result on my last foray into OOP was three tidy function calls to a cfc that turned (what was) 500 lines of copy and paste spaghetti code into:

usercfc.createAccount(somestruct)
usercfc.updateAccount(somestruct)
usercfc.deletedAccount(somestruct)

Fergolicious!

WTF? Errr... I mean What the Font?

This is a handy tool for figuring out what font is used in a graphic. All you do is upload an image that contains the font and it asks you to identify some highlighted letters and it will give the closest matches.

http://new.myfonts.com/WhatTheFont/

It doesn't provide the font for download but if you Google the font name there is a good chance you can find a free version (or a free knock off version).

Google Chrome Portable (Win only)

Download Google Chrome Portable

Google Chrome has some AWESOME debugging features including my favorite, Right Click >> Inspect Element. I would seriously recommend taking a look at Chrome for CSS debugging.

I looked at the user agent and it is nearly identical as Safari. It had almost the same build so (I would assume) they are essentially the same browser.

HTTP_USER_AGENT=Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/1.0.154.42 Safari/525.19

Portable version of the Safari Web Browser

I am a huge fan of portable apps. I like being able to drop an app in a folder and not have to install it. You just put them on a portable or thumb drive and you are good to go. Actually I have a version of almost my *entire* dev environment (sans MSSQL, that is next) on a thumb drive. I can literally set up shop anywhere (on a Win box).

Any who, I needed to test a design against the WebKit browser, the engine behind Chrome, Safari and (I think) it is used by DW for it's Live View feature. So here are links to versions for both Mac and Windows:

"http://www.thindownload.com/app-download/47/Safari-Browser (Win)

http://osxportableapps.sourceforge.net/p_safari/ (Mac)

Amazing Website To Build (CF) Eclipse installs

One of the biggest pains in the arse when dealing with some FOSS apps (LAMP especially) is dependency hell. If the app you need is not part of the package manager you can get into a day(s) long hunt for dependencies.

The same is true for Eclipse (to a lesser degree). Or rather it was.

Someone on CF_talk was having problems with installing CFEclipse on the latest version of Eclipse 3.4 (Ganymede). In the past a few people recommended Pulse (myself included) to deal with Eclipse's dependencies. Pulse is a great app that resolves dependencies (most of the time) when building Eclipse Distros. Pulse is an excellent product but has a bad habit of downloading a gig or more of files (in my case) to its plugin cache (depending on your builds).

Another option, and in my opinion a better option, is yoxos.com's On Demand website. http://yoxos.com/ondemand/

Yoxos.com's On Demand website is an online tool for building custom Eclipse distros/installs. This site is one of the most amazing web based apps I have seen to in my life. The front end is damn near that of a desk top app, and the back end is even more impressive. It allows you to pick and choose from hundreds of plugins and automatically resolves dependencies so you can create custom Eclipse installs that you can save, merge and share.

I started messing around with the various plugins and found some of the most amazing tools like editors for PHP, SQL, CSS, (X)HTML, JavaScript and XML with support for Adobe AIR apps, all the major JS/AJAX libraries with code assist and inline help; wussywig HTML editors, JavaScript debuggers, XML schema editors, JavaScript/CSS/html function/property browsers, Database development tools and editors, snippets etc. etc. Not to mention Eclipse is the defacto standard for Java development and supports most of it's tool kits as well as having plugins for just about every language under the sun.

And keep in mind that a lot of the above editors are not just text editors with color coding and rudimentary code complete but first class, full featured tools/IDE's like the ones that we used to (and still do) pay hundreds of dollars for.

Oh yeah. It is all FREE!!! FOSS, me love you long time!!

InfoWorld story: Developers rank best application servers - Adobe ColdFusion among their favorites

This is AWESOME!! The story was included in the "InfoWorld Platforms Report" Newsletter.

Developers rank best application servers
"The 'user's choice' for application servers ranked Adobe ColdFusion, the open-source Apache Geronimo, and Oracle WebLogic Server among their favorites"

http://www.infoworld.com/article/08/10/22/Developers_rank_best_application_servers_1.html?source=NLC-PLATFORMS&cgd=2008-10-22

This has been a LONG time coming. I am guessing that CF isn't all that dead. In fact it may be, to quote Adam Lehman, the "Best dead language... evar!"

More Entries

That's right bitches!! Free ColdFusion!!

Recent Entries

Calendar

Tags

NAVIGATION

Recent Comments

RSS

Search

Subscribe