Archive for November, 2006

GRG 301K Place Name Exam - Google Map

Wednesday, November 15th, 2006

I developed a nice little web page as an exercise in Google Maps and to help study for a Place Name Exam in one of my classes, GRG 301K. The test is over a set of locations. A map with numbers will be provided and each question will name a location and ask (multiple choice) which location on the map matches that name. My Place Name Exam - Google Map page is a tool to help study for the exam.

The locations are divided up into categories (as provided by the professor). Clicking on a category on the left will bring up markers on the map corresponding to the locations in the category. Clicking a marker will identify the location in an info window/balloon. Clicking a particular location within a category will center the map on the marker for that particular location.

(more...)

Instantiation order with extended components

Wednesday, November 8th, 2006

The particular order that a child and parent component are instantiated should be noted. The initialization code, that is, the code in a component that is outside cffunction tags, is executed first in the parent. For example, if you have a parent/base component:

Code (coldfusion)
  1. <!--- employee --->
  2. <cfcomponent>
  3.   <cfset this.salary = 50000>
  4.   <cfset init()>
  5.   <cffunction name="init" access="public" returntype="employee">
  6.     <cfset this.overtimeSalary = this.salary * otMult()>
  7.   </cffunction>
  8.   <cffunction name="otMult" access="private">
  9.     <cfreturn 1.5>
  10.   </cffunction>
  11. </cfcomponent>
and a child component:
Code (coldfusion)
  1. <!--- manager --->
  2. <cfcomponent extends="employee">
  3.   <cfset this.salary = 70000>
  4.   <cffunction name="init" access="public" returntype="manager">
  5.     ...
  6.   </cffunction>
  7.   <cffunction name="otMult" access="private">
  8.     <cfreturn 2>
  9.   </cffunction>
  10. </cfcomponent>

then instantiating an object of type Manager will have a salary property set to 70000, because the cfset runs in Employee first, and then in Manager.

This makes pretty good sense to me. The values of the child component override the values set in the parent.

This doesn't apply only to variables being set, though (whether it be the public this scope or the private variables scope). If you call a function from the initialization code of a parent component, the function is called as it exists in the parent - the child part of the object has not been instantiated yet.

So with the example components above, the call to init() from within the initialization code of the parent component, Employer, makes a reference to the otMult() function. Since the child part of the object has not been instantiated yet, the otMult() call returns 1.5, instead of the value of 2 you might want if you are instantiating a Manager.

If this becomes a problem for you, I suggest that you NOT try to call your initialization functions from the initialization code block of a component, and instead, put all your initialization code within init functions and call your init() function when you instantiate an object:

Code (coldfusion)
  1. <cfset myManager = CreateObject("component", "Manager").init()>

Happy Coding!

Books

Sunday, November 5th, 2006
I'll be graduating from The University of Texas at Austin soon. As my schooling is coming to an end - at least for a while - I've been feeling more and more like now my education can finally begin! Lately, I've been coming across a whole bunch of topics I'd like to learn about and books I'd like to read. I've added a page on this site to list some of the books I'd like to read, and some books I'm currently reading or have recently read. Take a look and read a book! ...Honestly, I didn't mean to make that rhyme, it just came out.

Welcome…

Friday, November 3rd, 2006
Welcome to my blog. I've been developing web applications, mostly in ColdFusion, for several years. I hope to use this blog to share lessons learned, tools I've developed that I think others might find useful, and anything else I think up to share. I welcome your comments and hope that someday, someone will find this site useful. I just threw the template together, so the XHTML and CSS are a little rough. I'll try to get around to cleaning it up a bit some day.