Showing posts with label OOP. Show all posts
Showing posts with label OOP. Show all posts

Saturday, August 2, 2008

Strange behavior, objectid() method in component.cfc

So I was working on something OOP :-). And I am trying to use Hal Hellms BaseComponent.cfc that all CFCs that don't extend anything should extend. For the purpose of this post I reduced it to two methods:

The way I was using it is I included it into ColdFusion component.cfc that all CFCs extend by default:

So I also make test CFC and a cfm page:


When I run cfm file and expend the dump output I see following:



As you can see the objectid() method is missing.

Now I remove the include from component.cfc and make my test component extend BaseComponent

Run cfm again and get following:


Now objectid() method is seen in the dump.

Saturday, July 19, 2008

Object collection class with iterator

So I added an iterator to my collection cfc. Several people blogged about using java iterator for coldfusion arrays and looks like Transfer uses those.

Here is an iterator method:

I also changed getBy() and removeBy() to use iterator:

Also have to plug MXUnit. Using it made refactoring like that above, much more enjoyable.

Friday, July 18, 2008

Object collection class

This is collection cfc that's largely based on one I found here.

I added couple of methods, getBy and removeBy that I think will be helpful for working with collection of objects. Each takes a property and a value of that property as arguments, then we try to match those to one of the objects in the collection.

Now I need an Iterator for this.