Compound Theory

v2.0

Categories

  1. Transfer
  2. ColdFusion
  3. JRuby
  4. Java
  5. ColdSpring
  6. Squabble
  7. JavaLoader
  8. ColdDoc
  9. 2ddu
  10. AsyncHTTP
  11. OO Analysis and Design
  12. Flex
  13. Railo
  14. XML / XSL
  15. Hibernate
  16. ColdFusion Builder
  17. Fall
  18. Ubuntu
  19. XHTML / CSS
  20. Eclipse
  21. Git
  22. Oracle Database
  23. Usability / UI Design
  24. webDU
  25. cf.Objective()
  26. LWJGL
  27. cf.Objective(ANZ)
  28. Captcha
  29. MAX
  30. Melbourne CFUG
  31. Martial Arts
  32. Random Things
  33. Conduit

Recent Posts

Projects

Recent Comments

31 March 2005 10:35 AM 21 Comments

CFC typing WTF..... ???

Okay - a bit of a rant... and this has probably been shown before, but this definatley threw me when I saw it..

1st off. I hate having to use a CF mapping when using CFCs. Totally defeats the purpose of portable/reusable code in my mind.

I've been playing alot with trying to keep my code non-mapping required. It's been taking it's toll, but I'm sorta-kinda getting there.

So with that in mind, I started a recent project with all my CFCs in one directory, so they could see each other, with the idea of refactoring into packages last, once I was happy with how it was working.

So I start refactoring, and I run into this fantastic doozie.

Example is:

Directory structure
/webapp/index.cfm
/webapp/Test.cfc
/webapp/com/dog.cfc

Code
--- dog.cfc ---
<cfcomponent name="dog">
</cfcomponent>
-----------------

--- Test.cfc ---
<cfcomponent name="Test">

<cffunction name="init" hint="Constructor" access="public" returntype="Test" output="false">
<cfscript>
var dog = createObject("component", "com.Dog");
setDog(dog);

return this;
</cfscript>
</cffunction>

<cffunction name="setdog" access="public" returntype="void" output="false">
<cfargument name="dog" type="com.dog" required="true">
<cfset instance.dog = arguments.dog />
</cffunction>

</cfcomponent>
----------------------

 

--- index.cfm ---
<cfscript>
createObject("component", "Test").init();
</cfscript>

--------------------

Problem
So, basically, what happens is: You create a new 'Test', it creats a new 'com.Dog', and then when you go to set it via the setDog(), it tells you:

The argument DOG passed to function setdog() is not of type com.dog.

WTF? Your telling me, that you can work out in relation to the Test.cfc enough information to create a 'com.Dog', but you can't work out the same thing for typing on a cfargument???? Why bother giving us the one, if you can't give us the other?

I just wish that Coldfusion had a way that was either designated, or programtically determ a single root directory for all your CFCs to reside. Much like a J2EE app has /WEB-INF/classes for .class files to reside. That way you COULD have packages much like you can in Java, and not have to worry about portability issues with cfmappings.
(I also wish for the ability to jar up a series of CFCs and import them as a library, again like J2EE... but I think that is asking too much)

As it stands, I think I will experiment with having all my CFCs in one directory, and see what issues arise. It's not an ideal soultion by a long stretch, but it allows me to develop without mappings for now.

-- end rant

26 March 2005 07:22 PM 6 Comments

Using a java.io.BufferedReader in ColdFusion

So I'm parsing through some response text I get from a CFHTTP I'm firing off, and I figure - the easiest way to parse through this thing, is actually going through it line by line.

There are a variety of ways I could have done this particular endevour, but I figured I build myself up a java.io.BufferedReader that I would pass my String into (via a java.io.StringReader), and I could loop around the thing till my heart was content.

Only issue is this - the only way to tell if the BufferedReader is done, is that it returns null from it's readLine() method.

Doh. CF doesn't handle null values all that well.

So I figure - maybe it will return an empty string? Who knows. I'll set it up like I would in Java and see what will happen.

1st round starts like this:

stringReader = createObject("java", "java.io.StringReader").init(response);
bufferedReader = createObject("java", "java.io.BufferedReader").init(stringReader);
while(Len(line = bufferedReader().getLine()))
{
  //do stuff
}


Which unfortunatley doesn't work too well - as CF won't handle the evaluation inside parenthesis, and thinks the = is my mistake for 'eq'. So we switch over to a do ... while loop instead, and get:

do
{
   line = bufferedReader.readLine();
} while(Len(line));


Which works - except it returns back an error: 'line is not defined'.

Which I realise (but fail to understand) is that when Java returned the null value out of the method, it actually removes the line variable from the scope of the method! Woah!

So in the end, this is what I end up with, and it works a treat:

stringReader = createObject("java", "java.io.StringReader").init(response);
bufferedReader = createObject("java", "java.io.BufferedReader").init(stringReader);

do
{
   line = bufferedReader.readLine();
   lineCheck = isDefined("line");
   if(lineCheck)
   {
      //do stuff
   }
} while(lineCheck);


This works perfectly, and now I can use by StringBuffer Happily!

17 March 2005 10:43 AM 0 Comments

Mike Nimer's CF Log Plugin

Yet another reminder I should get off my lazy butt and do some CF/Eclipse work -

Mike Nimer decided to build himself a CFlog viewer and it's pretty neat too.

To copy and paste - it's features include:

Nice work Mike!

10 March 2005 09:55 AM 3 Comments

Happy Birthday to Me!

It's my 25th birthday today!

Things I want to do in this year of my life:

  1. Make my fiance as happy as possible
  2. Have a wonderful time at my wedding
  3. Get some dogs
  4. Buy a house
  5. Hang out with all our friends
  6. Do some work on CFEclipse
  7. Rewrite Compound Theory
  8. Release some open source software
  9. Keep training martial arts

Of course that's in no particular order (except for the fact my gorgeous fiance comes first)

:o)