I hear alot of arguments (particularly of late on the CFAUSSIE mailing list) about ColdFusion and Object Oriented Programming.
It seems that almost even the most tangential conversation that could possibly relate to OOP, degenerates into pointless bickering about how OOP is good, bad or ugly when combined with CF. It's verging on rediculous.
The facts remain as such - Object Oriented programming has been THE software development paradigm for more years than I have been alive. There is a REASON why we don't code in procedural code anymore, and a REASON why Object Oriented programming has come into almost every aspect of software development.
Looking solely at Macromedia related products. CF was procedural, and then came along CFC's. Flash was... well, Flash... and now you can define classes in Actionscript. Blackstone will further enhance CFC's with Event gateways and the like.
The truth of matter is - the Future for Coldfusion IS OO. You can like it, you can hate it, but quite frankly, if you develop with CF, Object Oriented programming is here to stay, and there is nothing you or anyone else can do about it. All it's every going to do is infiltrate more and more of the CF development community, as the years go by, and the support for it in future ColdFusion versions grows.
Yet again, I implore you - if you want to develop your software development abilities with ColdFusion go and drop into a Java course. Not only will it give you the theory you need to stay with the time in ColdFusion, but it also provides you with the ability to combine CF with it's sister language, and give you capabilities with this language you never had before.
Can that really be a bad thing?
Via Ben Forta
An unofficial beta application has been posted at http://www.surveymonkey.com/s.asp?u=1282566342.
Quite frankly I don't care if it's 'official' or not, I'll take any chance to get onto the beta! :o)
Can't wait for BlackStone!
This is a bug that I've been getting on here for a while, and I've been meaning to fix it. Strangely enough today is the day!
The issue comes when either an older browser, or a badly implemented RSS reader picks up my links.
Since both my webpage is and my RSS feed is XML (XHTML), I will turn a link that looks like /?action=displayPost&ID=99 into one that looks like /?action=displayPost&ID=25, as '&' is not a valid XML element.
This is normally no issue, but sometimes I do get requests that still retain the & within the URL, as it hasn't been translated back to the normal ampersand.
My original thought was to fix the issue with a <cflocation>, however I didn't feel that would be seamless enough, and if there was form data going through, that wouldn't work either.
So I used getPageContext().forward() to forward on the request, after I fixed it by replacing all '&' with '&' in the url query string, and because the forward() method simply pushes the java HttpServletRequest and HttpServletResponse objects through to the new request, everything is totally seamless. Form data gets passed through, and the user won't even see a URL change in their browser.
Here is the code below - I have it in a custom tag called 'fixAmp.cfm' that gets called in my Application.cfm
<cfparam name="request.fixAmp" type="boolean" default="false">
<cfif (NOT request.fixAmp) AND (findNoCase("&", cgi.query_string ) gt 0)>
<cfscript>
request.fixAmp = true;
queryString = replace(cgi.query_string, "&", "&", "all");
getPageContext().forward(cgi.script_Name & "?" & queryString);
</cfscript>
<cfabort>
<cfelse>
<cfscript>
//just for cleanup
StructDelete(request, "fixAmp");
</cfscript>
</cfif>
The reason I have the request.fixAmp flag in there is because on some servers, if you forward the request, the CGI data will stay the same. Hence the tag will go into a infinite loop as it never think's it's fixed the ampersand.
And presto, you never have to worry about issues with useing & in your links again!
Opened up my Eclipse, and got notified that there is now a 1.1.15 version of CFEclipse! (I should have known this anyway as I'm on the mailing list, but looks like I missed that one! Ooops!).
Looks good! Some new features are sweet - particularly that you can now sort CFC methods to alphabetical and back again, in the CFC methods viewer.
The new snippet preview is nice, and the snippet trigger is good - however it is a tad buggy so be careful.
- You can't use a trigger that is only a single character - so don't even try. no 'c' or 'f' or 'g'. It has to be at least 2 characters.
- When changing your snippet triggers, they may not show up as changed when you look at it again - this is because the plugin doesn't actually delete the old trigger, so it will still be able to be used. So I suggest choosing wisely before setting your triggers. (That being said, you can manually change triggers via the \eclipse\workspace\.metadata\.plugins\com.rohanclan.cfml\keyCombos.properties file, it's pretty easy, and takes effect straight away)
- Supposedly you need a whitespace character before your trigger, otherwise when you hit CTRL+I, it won't work. I haven't seen this one happen, but keep an eye out for it.
Overall, however, the upgrade is nice, provides some good bug fixes, and these bugs can be worked around.
Oh yeah - and despite the controversy, they are still using my Icon ;o) (Although I'm sure someone will come up with something better eventually).
Enjoy :o)
Sorry about the server dropouts everyone.
Not much I can do about it (it's not my apps fault! ;o) ) and they should hopefully be resolved shortly.
Thanks for your understanding.
Just moved the development of an app from Windows to a J2EE instance on a Unix server, and quite frankly, not nearly as hard as I thought it was going to be.
Took a little while longer than expected as they had also set up .htm and .js as ColdFusion extensions, and that threw a few bits and pieces out of whack.
Obviously hit the CaSe sEnSItIVitY Issue, but with a few global find and replaces, that soon went away. That and I also tend to stick to a pretty standard naming convention, so it didn't bite me as hard as it could.
Filepaths got me a little, as Windows will take c:\mydir\/thisplace/file.txt or c:\mydir\\images\image.txt etc as a valid path, whereas Unix only likes the / operator. But that didn't take long to fix either.
So, all in all migration, pretty easy! :o)
I was never entirely sure as to whether or not ColdFusion booleans where short circuit or not.
(If you are not sure what a short circuit boolean is - check out this article)
I got a tad bored, so I decided to run some tests to see what was what, and lookee here, CF uses short circuit booleans.
I have a feeling in 6.0, this wasn't always the case, but in 6.1 it is definatley the case.
Pretty simple testbed - 2 funtions:
<cffunction name="ftrue">
<cftrace text="true" inline="true">
<cfreturn true>
</cffunction>
and
<cffunction name="ffalse">
<cftrace text="false" inline="true">
<cfreturn false>
</cffunction>
and so I ran some tests, and these are the results i came out with (somewhat stripped):
true & false
[CFTRACE] - true
[CFTRACE] - false
--------------------------------------------------------------------------------
false & true
[CFTRACE] - false
--------------------------------------------------------------------------------
true & true
[CFTRACE] - true
[CFTRACE] - true
--------------------------------------------------------------------------------
false and false
[CFTRACE] - false
--------------------------------------------------------------------------------
true or false
[CFTRACE] - true
--------------------------------------------------------------------------------
false or true
[CFTRACE] - false
[CFTRACE] - true
--------------------------------------------------------------------------------
true or true
[CFTRACE] - true
--------------------------------------------------------------------------------
false or false
[CFTRACE] - false
[CFTRACE] - false
--------------------------------------------------------------------------------
(true or false) and true
[CFTRACE] - true
[CFTRACE] - true
--------------------------------------------------------------------------------
(false and true) and false
[CFTRACE] - false
So what does this mean? Well, for starters - you can do things like this:
if(isDefined("x"))
{
if(x eq 1)
{
x = x + 1;
}
}
can become
if(isDefined("x") AND (x eq 1))
{
x = x + 1
}
Without any fear of error, because if the isDefined() fails, the short curcuit doesn't have to check the right hand side, as false and true will always equal false, no matter what.
It's an interesting thing to note when doing your boolean logic, and should open up some interesting ways of making some algorithms just a tad bit faster.
I get bit by the multithreading bug on a regular basis. This site has had it's fair share (and I think I've managed to remove them all out by now).
Generally I find that multithreading bugs mostly occur when you store CFCs in shared persistant scopes, such as application or server.
So as a rule of thumb to make sure you don't get bit by the dreaded multithreaded bug, here are my tips and tricks:
- Use CFMX 6.1. It is possible to do persitatant CFCs with 6.0, but it's really not consistant in it's applications.
var all your local variables within CFC methods. This is my NUMBER 1 cause of multithreading issues, I forget this all the time.- Use the
arguments scope when referring to arguments passed through in the CFC method. (This would be my number 2). var all your local variables within CFC methods. This is SO important, I'm going to write it twice.- Refer to instance variables by some sort of scope, beit directly through the
variables scope, or if you use an instance struct of some kind, use that. Use appropriate locking to ensure that data corruption doesn't occur. As far as I am aware, CF arrays are not thread safe, so write appropriate locking when dealing with them. I find named locks do the job nicely.
EDIT :::: Actually, I retract this statement. I did some investigating, and the Java array extends java.util.Vector, which IS thread safe. To quote from the relevent javadocs "As of the Java 2 platform v1.2, this class has been retrofitted to implement List, so that it becomes a part of Java's collection framework. Unlike the new collection implementations, Vector is synchronized.". I had originally thought that the ColdFusion array extended java.util.ArrayList, which is NOT thread safe, and requires itself to be constructed through java.utils.Collections.synchronizedList() to be thread safe. My bad.
- Write an error handler that sends you emails when an error occurs. Just because you don't see it, doesn't mean it doesn't exist, and multithreaded errors tend to be a sneaky little bunch. I have a tendency to use a modified version of the DumpVar udf from Cflib that outputs strings with a
XMLFormat() on them, and then dump out the error, CGI and Form structs to the email. - Use some sort of stress tool (I've been using the MS Web Application Stress tool) and catch any and all the emails that come out of your above error handler. Fix these bugs. Rinse and Repeat.
That's pretty much it. That should make your CFCs thread safe.
It seems really simple, but I get caught with it so often (damn being used to declarative programming languages!) I figured I would write up a post.
Let me know if you have any other tips and tricks that help you stave off the dreaded multithreading demon.
My girlfriend and I had an incedent the other night, that threw me a little, so I thought I would share it.
We were walking my dog around 8:30 - 9:00 pm, when a woman across the road called to us and asked us if we had a mobile. This happened to be one of the few times I didn't have my mobile with me, but we walked across to talk with the woman. She'd found a beagle that was wandering around, and she then preceeded to unceremoniously dump the animal onto us because she was in a hurry.
Now my girlfriend and I are long time animal lovers (both of us have pets), so we were happy to sort the situation out. Unfortunately, while the dog had it's registeration tags, but no name tag, and no home phone number.
We managed to get a mobile, and made some phone calls to the local council and such, but of course being after hours, nobody was particularly helpful.
Thankfully, the owner of the dog ran into my girlfriend as I was holding this dog down the street, and they were both happily reunited.
However - if the dog had had a name tag with it's phone number on it, this could all have been easily avoided, and there would have been far less chance that someone would have ended up leaving the dog to be 'someone elses problem', when they are 'in a hurry'.
So please, put a name tag on your dog, and put a home phone number on it.
I never do quite understand why I derive such delightful pleasure out of developing icons.
Maybe it's just because they are so cute. or maybe it's because it's a rare day when I leave my code, and have a play with colours and shapes.
I thought I would do a second impression on eclipse and cfeclipse, simply because I've been using it for the last few days, and have really had a chance to get into it.
Quite frankly, I love it.
The new verison (1.1.13) has just come in, with some great bug fixes, and it is so nice to use.
Things I love about cfeclipse:
- Snips - These things totally rock my world. The fact you can code in user variables, and have default values such as $${MONTH} and $${CURRENTFILE} provided for you, make things SO easy. Before I started using these, I missed all the Homesite tag editors, just because of the speed. Now I just make a small snip with custom elements, and presto, it's pretty much the same. (Keyboard shortcuts for snippets are coming, which is good).
- CF Outline view and CFC Method view. I've been dying for these for a while. I'm so used to them in Java IDE's, it's great to have them here too.
- I do all my editing in a single IDE. I love that, it saves me so much time.
- The fact that CFEclipse is has a strong, driven development team. I love the fact that I can go 'you know, it would be nice if you had void on the code completion for cffuntion', and look, it's there in this release. Failing that, I'll go write it myself (as soon as I get some time to play with eclipse plugins).
Things I don't like about cfeclipse.
- The new icon. I totally understand why you changed it, but UGH! It aint pretty.
Things I use with cfeclipse (half covered with last post)
- CSSEditor - works fine with 3.0, hit ctrl+space, and you have some css completion. Perfect for what I need.
- JSEditor - The guy who made this has dissapeared, but it's neat, and has code completion too.
- XMLBuddy - The free version of this is really good, and I'm seriously contemplating buying a pro version for XSL work. (I can't find a decent XSL editor for Eclipse that is free.)
My contributions
- A new icon for CFEclipse.
(Right click and save as). Pop it in "/eclipse/plugins/com.rohanclan.cfm{version}\icons\obj16\", and you have a nice pretty blue document. I had to do this, because I really didn't like the icon.
- Comment Header Snip - I used the old comment header extension for Homesite+ alot, so I made a snip that emulated it. Here you go. Drop this in your snips directory, and you can use it as you see fit.
There we go. Download Eclipse. Install CFEclipse. Have some fun.
Go on. Do it.
Do it. </bad Starsky and Hutch Reference>
Well, I've got some UTF-8 Coldfusion development I am working on, so I was forced to ditch Homesite+, and find an editor that I could use that would support Unicode.
There was no way I was going across to Dreamweaver (heh), so I figured it was about time to check out Eclipse and CFEclipse.
I also generally liked the idea of not having to shift between IDEs as I work - no more flitting from Homesite to Topstyle to XmlSpy... etc etc. It would all be contained within the one IDE and it would be wonderful.
Well at least that was the idea.
I grabbed a copy of Eclipse 3.0, primarily (a) because CFEclipse only runs on 3.0 and (b) I love having new things. The install ran fine, after I moved past a small JRE issue that some Oracle software had pushed via a only JRE 1.3 lying around after my machine without too much trouble.
Then I hit my first issue. Tigris.org is all in Japanese for me, except for some english. That made getting cfeclipse a tad tricky. No idea why it is. Sent the website a email today, so I'll let you know when I get a reply.
Managed to get it down, and installed it - no issue. Sweet. Open up eclipse, create a new project, yup all looks good.
Find some small issue with CFeclipse, nothing major, but I wanted to report it, or see if it was going to be fixed. (I'm running verison 1.1.9 beta)... oh yeah, can't do that because the site is in Japanese. Sod. Well I'll subscribe to the mailing list... yeah... can't find it because my Japanese isn't so good.
EDIT ::: Looks like all my winging produced some effects! I can now see the site in English. That's brilliant, now I'm going to sign up.
Fired off an email to CFAussie, and got subscribed to the mailing list. Going to post up some bugs soon, hopefully I won't be stepping on anyone's toes because I can't find/read the bug tracker.
So now I need a CSS editor... awesome, plugin "CSS Eclipse Plugin" into google, and got the csseditor plugin for eclipse. Allright. Load that in.. and.... now I have some basic CSS validation. It's no topstyle (lite?) but it does the trick... that's cool, it's open source, and it's free, and my css is decent enough (although a colour picker would have been nice. Maybe I can find a plugin for that in Eclipse).
EDIT ::: I discovered the documentation for the css editor, and of course you can hit 'ctrl + space' and it will get some content assistance - so all in all, a pretty good editor!
So I go hunting a XML editor too, because I do a fair bit of XML work. I found x-men, looks great! nope.. doesn't work with 3.0.. I end up going with XMLbuddy, which looks good, but unless I buy the pro version, isn't going to do all of what I want.
So overall, I'm doing okay - I've started developing with Eclipse, and I'm loving the CFC method view and Outline view of CFEclipse, it's something I've been dying for for ages. So that stuff does rock.
Eclipse and it's range of plugins so far seem to be good but not great. This is probably a gripe coming from soneone who is used to really mature commercial software, and so there is that bias. So factoring in what you can get for free out of eclipse it is pretty darn good. However, to that point, I found the support of 3.0 to be quite lacking by alot of the plugins out there.
So I do want to say that Eclipse (and said plugins) are really good products considering the relative time they have been around, and the fact that they are developed as open source, free products.
I'm going to complete this project with Eclipse before I decide it's a keeper or not, but if you develop with ColdFusion and you don't want to user Dreamweaver, and you are afraid Homesite is going to be a dead end, I highly suggest that you give Eclipse a go. That and the ability to really extend your IDE yourself is a very powerful feature.
Just bring a monkey wrench in case things go wrong ;o)
I'm not sure what I did, but I was trying to respond to the Struts mailing list subscriber, so I could validate my email address... and all of a sudden all I ever get when I try and send emails is 'An error has occured. This email was not sent'.
This is ANY email, i can't send any emails at all.
Ah well ;o) This is why it's a Beta program.
Anyone else had the same issue and know if I can fix it myself?
I've sent a message to Gmail, and hopefully it fixes itself soon, it really is great as a repository for mailing lists.
EDIT :::
Whoo! It works again! Man, those Gmail guys (or girls) are fast.
I think I'm going to see all my mailing lists go over to gmail! :o)