The amazing adventures of Doug Hughes

Archive for June, 2007

Heading Out to CFUnited

I’m headed out within the next few hours on a 6 hour drive up to Maryland for the CFUnited conference. Although I’ll be attending a few sessions, my main motive is not educational this year. Instead, I’ll be up there looking to drum up business and “pressing the flesh”.

If you or your company have a need for some world-class ColdFusion or Flex consulting please look for either myself or Scott Stroz. We’ll be happy to discuss whatever is on you mind!
I hope to see you at CFunited.

Frameworks BOF at CFunited, Wednesday at 9pm

As Joe announced yesterday, on Wednesday at 9pm there will be a frameworks BOF (birds of a feather) session. I expect Ill be there to represent Reactor and, maybe, an as of yet unannounced framework. Maybe, just maybe, if you attend the BOF youll learn the (suggestive) name of this new framework!

At the same time, Scott will be giving his Prototyping Applications in Flex presentation as a BOF session. This was moved due to a scheduling conflict with another presentation.

Whichever you choose, we (Alagad) hope to see you there!

Off to Flexmaniacs, then CFUnited

I am getting ready to make the hour or so trip down to Washington DC for Flexmaniacs. If you have not heard of it, Flexmaniacs is the first Flex-centric conference on the East Coast. I am giving two presentation during the 2 day conference. My session topics are ‘Printing in Flex 2’ and ‘Sorting, Filtering and Paginating Data in Flex 2’.

After the conference ends on Tuesday, I will be heading up the road for CFUnited. As I mentioned here, there were some scheduling issues with my ‘Prototyping Applications in Flex’ session. TeraTech has graciously given me a ‘Birds Of a Feather’ (BOF) session on Wednesday night, at 9:00 PM, to discuss the materials which would have been presented during the originally scheduled time slot.

Its going to be a busy, but fun week. Hope to see you at one or both of the conferences!

Variables.Instance

This week I was walking through some code in a code review and the question came up, why do I use the “extra” instance structure within my components. For example, in my init() function for every component, I have a line of code that looks like this:

<cfset variables.instance = structNew() />

Then, when I setup a new attribute for the component, I would store it in a variable like this:

<cfset variables.instance.foo = "bar" />

So, beyond personal habit, why do I do this? There are several reasons, some of which may be more valid in different contexts.

  1. It tends to make variables more obvious in the code so that you know what is a local variable for a function versus a global attribute for the component.
  2. You can dump this structure and see a quick snap shot of the ‘state’ of the component. While you can dump the variables scope, you will not only get the variables but also lots of function meta data which is not always desirable.
  3. For the OO purists out there, having all of the attributes contained within a structure like this makes it very simple to write the equivalent of a “copy” constructor.
  4. For components that might be extended in the future by yourself or another developer, you run the risk of variable collisions – that is variables with the same name in the base component as well as the extended component. By using a specially named structure for your instance variables, this can be prevented.

I don’t know if this was reason enough to convince my colleague, but it is reason enough for me to keep doing this in my components. Is this a wide spread best practice or am I the only one?

Give it to me!!!

If you are going to be attending CFUnited and would like to help the Make-a-Wish Foundation as well as get out some pent up frustration, check out what’s happening Wednesday night.

Service Layers, an Analogy

I’ve been working with a programmer recently who is new to both design patterns and object oriented programming. He’s been maintaining some old code I wrote a while back and trying to change how it behaves. Obviously, this could be challenging for someone who’s new to OO.

So, the other day he asked me to explain what Service Objects are. I tried to explain the nature of the Faade design pattern and how a service is simply a faade for more complex operations in your system. I tried to explain that it’s a good practice to wrap all of your model objects to make it easier to expose this functionality to various systems.

Honestly I wasn’t terribly successful with this explanation. In his particular case his service was going to use a gateway object (yet another design pattern) to get a query and return it. But, if the service is returning a query, how does the service differ from the gateway?

I had to think about how to explain this, and what I came up with was this analogy:

Let’s say I ask you to get me a nice frosty mug of beer. If you agree to get me this cool, refreshing, beer, you’ll be performing the service of getting a beer. You, you’re a service object. You perform a service.

Now, personally, and I’m not trying to be rude here, I honestly don’t care how you get the beer. You could run to the store and buy a mug, some dry ice, and a six pack. You could go to the neighborhood pub and run off with a fresh drawn beer. More likely, you’ll just walk (heck, you could run or skip, for all I care) to the fridge, grab a beer and poor it into a mug, and bring it back to me. And, just to illustrate my point again, you could use a bottle opener, your teeth or any other mechanism to open the beer. To me, those are just (implementation) details that don’t matter, so long as I get my frosty mug of beer back.

Now, let’s think about what you care about as the service. Do you care how the fridge stays cold? Do you care how it was manufactured? Do you care how the beer was brewed? You might care what brand of beer (microbrews only, please), but chances are that’s already a constraint of the system you’re running in. You don’t care how long the beer was fermented. You don’t care how long the mugs are kept cold to make them frosty. All these details are the responsibility of other systems that, though essential ultimately, to you, my BeerService, being able to successfully get me my beer.

So, lets break the analogy down a bit. Who are the players and what do they represent?

Me/I. I represent any system which uses your service. I could be a remote faade used by flex. I could be a controller in your MVC framework. I could be another service that just really needs a beer.

You. You’re a BeerService component (or maybe a BarTenderService). You have a set of methods related to beer (or bartending, I guess, as the case may be). For example, getBeer(), restockBeer(), cleanMugs(), wipeUpSpills(), cutOffUser(), etc. As the user of the service, I don’t care how you get these things done, you just do them, far as I’m concerned.

The Fridge, The Beer, The Mug, etc. These are components within your application’s model. In real computer systems these are objects that have specific responsibilities. For instance, the mug in our system is responsible for being frosty and holding beer. In a real system you might have a BeerGateway that is responsible for listing beers in your database.

I hope that helps clarify things!

Changing the Font Size in Eclipse

A couple weeks ago I was preparing giving a three day training class on Model-Glue and Enterprise ColdFusion Development. (Interested in some onsite training? Send me an email!) Unfortunately, the default font size in Eclipse is way to small to see on a projector. It took me nearly half an hour to figure this out, so I thought I’d post how to do this for posterity’s sake:

Within Eclipse click Window > Preferences. This will open up the Preferences dialog with gives you about a million configuration settings to tweak.

At the top of the list on the left you will see General. Click to open this. Next click Appearances. Finally, select Colors and Fonts from under Appearances.

This is where it gets confusing. Eclipse shows a tree of what appear to be languages or plugins or something. Underneath each one are many options for specific types of text. There are many choices in this dialog with no clearly obvious one.

Well, the one you’re looking for is “Text Font” under the “Basic” node. Select this and click the “Change” button that appears. From here, it’s just a matter of selecting the new font size and applying it.

Oh, and when you’re ready to go back to the old font size just click the Reset button to go back to your old settings.

Tag Cloud