The amazing adventures of Doug Hughes

Archive for October, 2008

I Learn Something New Every Day: ReturnFormat

I admit it, I rely on the hints available in CFElipse. And, for that reason, I never knew that the cffunction tag had an optional argument, new in ColdFusin 8, which controls the format in which data is returned on remote calls to functions. I ran into this argument accidentally. I was trying to call a function on a CFC remotely. For example, let’s say we have this basic CFC:

<cfcomponent>

    <cffunction access="remote" name="runTest" output="false" returntype="struct">
        <cfset var data=StructNew() />
        <cfset data.foo="bar"/>
        <cfset data.bar="foo"/>
        <cfset data.now=now()/>
        <cfset data.meaning=42/>

        <cfreturn data/>
    </cffunction>
</cfcomponent>

For those who don’t know, you can call remote functions on CFCs directly over HTTP. Just browse directly to the CFC and append a URL argument named “method” that names the method. For example:

http://scratch/remote/example.cfc?method=runtest

Now, the problem is, simply calling the method remotely returns your data in WDDX format. I know some people are fans of WDDX, but I personally find it next to useless.And it’s even more useless since it’s very hard to work with from JavaScript and pretty much any other language. So, what’s to do about this?

Well, the quickest solution, and the only one I knew until a week or two ago, is to add a “returnFormat” argument to the URL. Using this argument you can specify one of three formats: WDDX, plain and JSON. This will force the remote call to return data in the format you specified.

So, if you wanted to return your data in JSON format your URL would look like this:

http://scratch/remote/example.cfc?method=runtest&returnFormat=json

So, this works like a charm but you have to remember to add the returnFormat argument to the URL.

Well, last week, I just happened to be looking at the documentation for the cffunction tag and what do I notice? ColdFusion 8 introduced an attribute on the cffunction tag called returnFormat. And, much to my happiness, it works exactly the same as the URL argument on remote calls! I guess it goes to show you learn something new every day.

Stanford Engineering Everywhere

A while ago I came across the news that Stanford University had made available what they’re calling Stanford Engineering Everywhere, or SEE for short. SEE offers 10 of Standford’s most popular Computer Science classes on-line, in a self paced manner, for free.

The classes are split into three groups, Introduction to Computer Science, Artificial Intelligence, and Linear Systems and Optimizations. The course descriptions are available in the link above.

So, if I wanted (and I do), you could invest time to take these classes from Stanford for free. Now, it’s important to realize that you do not get anytime with instructors. Instead you can watch videos of the class lectures. However, you have access to the same lectures, assignments, exams and more used by Stanford students. And, to make up for the lack of instructor input, you have access to online communities to ask questions to.

Finally, and this is what I think is coolest, the work is licensed under the Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. This allows anyone to essentially to reuse, remix or rework the materials for non commercial purposes. Overall, I need to find a way to shave out an extra hour or two of my day to work through these classes!

How I Set Up My Development Environment

This post is mostly a re-post of one from my personal blog a few months ago, with a few minor changes. I have been asked about how I have my development environment set up a few times recently, so I figured this would be good to re-post.

Disclaimer: This is my preference and is not mandated by Alagad, though I think we all follow similar guidelines

I use Apache for my development web server, and for each project, I
set up a new ‘virtual host’ so that each project can run from its own
web root. I do this so that each development site runs from its own web root, just like production will. I give each project a ‘serverName’ like projectName.dev. This just helps me be aware of whether I am on dev or production, and makes it so I have to type less.

Then I set up a new entry in my HOSTS file for projectName.dev and point it to 127.0.0.1.

To make editing httpd.conf and HOSTS easier, I set up a project in Eclipse that points to my {apache root}/conf folder. Inside of that project, I create a linked file to my HOSTS file. Now from within Eclipse, I can edit my httpd.conf file and my HOSTS file.

I typically will structure my project so that I have a structure that looks similar to:

{projectRoot}
{projectRoot}/flex-src - if its a Flex project
{projectRoot}/support - this is where I put project documents, associated files, artwork, etc
{projectRoot}/wwwapp - this is the application root for my project. Typically this is where framework code, model code,etc will go
{projectRoot}/wwwapp/www - this is the web root for my project and where I would point Apache and contains all files that will be needed from any page such as JS, CSS, etc.

Obviously, as the project dictates, I will add other sub-directories. Also, when using SVN, {projectRoot} will typically be the ‘trunk’ of the repo.

Dynamic Programming and Metadata

In my last posting, the question was indirectly raised as to what I was talking about when I said “dynamic programming”. With our approach here at Alagad, dynamic programming means taking a very generic set of constructs and then applying metadata to them to make them useful.

For example, in our generic object management system, there is the concept of a “object” service layer and business object as well as a generic object data tier. By itself, all of this code is fairly useless. The key is the metadata that describes the “objects” within the current application. Thus, we take a very generic set of code, apply application specific metadata, and voila! we have application specific coding without really doing any new coding that needs testing etc.

For an example that more people would be familiar with, take your favorite ColdFusion framework … Model Glue, Mach-II, Fusebox, etc. By themselves, all of the code within these frameworks is useless until you add a configuration file describing the different events, controllers, and views that your application will handle. With the addition of this configuration file, you now have a very application specific code base without really writing much code.

So now that we have this generic set of code, how do we describe the intent of our current application metadata? There are quite a few possibilities out there, but the two that I have seen used most often are XML and actual code. Other options could include simple configuration files (csv, ini, etc), larger scale content management systems and a variety of other custom solutions that could go as far as writing your own language and associated parser.

One example of using code to describe your metadata is the FarCry content management system. It has been a while since I looked at FarCry, so excuse me if some of my terminology is not up to date. With FarCry, when you want to add a new property or data element to your content management system, you create an empty ColdFusion cfc which contains a series of tags. The FarCry core will then read these cfc files, interpret the tags and make the new data type available within the content management system. Now does not have the necessary attributes available out of the box, so FarCry makes use of a whole series of custom attributes on the tag. I believe you can also add custom functionality using <cffunctions within the cfc, but it has been a while.

On the plus side, this method of providing metadata to the FarCry core is easy for ColdFusion developers to understand as it is written in ColdFusion which we are all used to. At the same time though, this can be a minus if you were to have your business analyst drawing up the requirements for the system instead of using your development team.

When we developed our internal object management system, we made the choice to go with XML for the metadata. By going with XML, you literally have unlimited possibilities in what information you want to collect and how you want to represent it. As long as you stay within the syntax rules of XML, you can write your own language and through the use of a DTD or Schema, validate that whomever created a given XML document followed your language. By going this route, business users or analysts can easily create and provide for you the metadata needed for your system by just knowing the syntax of your language rather than requiring them to know about cfcs and tags. How much of a benefit to you this is obviously depends upon your situation.

So, are there other examples of metadata formatting and structure out there that you have seen or prefer?

Alagad Needs a Senior Flex and ColdFusion Developer

Alagad is hiring a Flex developer! I’m hoping to find one extremely talented Flex developer to join my team. This person also needs to be able to do advanced ColdFusion development, if needed. The person I’m looking for will have a lot of strong experience with enterprise development. So, if you’re a senior developer who wants to work from home, please waste no time in applying. Here are some finer details of what I’m looking for:

Languages

My team works primarily with the Adobe toolset. That is, ColdFusion, Flex and Air. Experience with additional Flex technologies such as LCDS and Blaze DS would be a bonus too. Though the person I’m hiring should primarily be a Flex developer, having strong experience with framework-based web development using ColdFusion is important. Unfortunately, as a consulting company, we can’t always control the presentation technology our clients use. We also do some fairly involved JavaScript and AJAX work. Advanced experience with Microsoft SQL is also necessary. I really need someone who solidly understands software development and who could, if the need was there, quickly learn something new and move forward with it. Virtually all the work we do here is Object Oriented. You need to understand OOP, design patterns, and more to be productive. Obviously HTML, CSS and XML go almost without saying.

Frameworks

Virtually every project we do at Alagad makes use of frameworks and so you will need to have experience using common Flex frameworks. Internally, we tend to use Simeon Bateman’s EasyMVC. We’re also interested in experience with Cairngorm or some other Flex frameworks. As for ColdFusion development, we typically use ModelGlue, ColdSpring and Reactor, though we also have been known to work with Mach-II, Fusebox and Transfer. We also have a few Alagad created frameworks to fit other niches For Javascript we’ve typically use jQuery as well as the YUI, Spry and ColdFusion’s AJAX features.

Authoring

I need someone who can talk and write professionally. When you’re speaking with clients you must sound professional and intelligent. Also, you’ll be required to write at least one technical blog entry per week and the occasional article for FAQU, Devnet, or other publications. You may even be asked to do the occasional user group presentation or talk at a conference. (All of this is on company time You work, I pay.)

Other Skills

There’s a good chance that I could throw just about anything at you. I need you to be able to roll with it. For example, sometimes I might need you to be able to take a PSD or jpeg image and turn it into a Flex interface or clean CSS and HTML. So, some experience with Photoshop or Fireworks would be a big help.

Mindset

I’m looking for someone with a great attitude. My goal is to be the best employer any one of my employees have ever had. If you’re too jaded to believe that I’m earnest (if not a little idealistic), please look somewhere else. I’m am trying to find ways to expand the compensation package to include profit sharing. For this to work well, I believe that we’ll all need to be committed. If you can come to the table with the appropriate brains and enthusiasm, we can all do well.

So, why would you want to work with me?

I’m striving to be the best employer in the Adobe toolset market. Alagad is, however, a small business. So, I need to be really creative in how I try to be the best I can be. Here’s benefits Alagad offers:

Hourly Pay

Are you sick of working 60 hours a week but being paid for 40? Well, first off, I rarely ask for any more than 40 hours in a week. But, if you do work more than 40 I’ll pay you for every hour you work!

Work from Home

All of Alagad’s employees work from home, wherever they are. Alagad has no real central office. This allows you to work wherever you want: Home, in bed, at the coffee shop, on an airplane. It doesn’t matter to me. What this means is that you get more time for yourself and your family. Alagad doesn’t require that you pay for the expenses and time of a commute. Heck, it’s even better for the environment!

Flexible Schedule

At Alagad we’re less concerned with the hours you’re in the office than that you get your work done. That’s not to say that we don’t want to talk to you during the day, but if you want to cut out early in the afternoon we simply don’t care. Do you need to pick you kid up from school? No problem. Life is full of interruptions. We don’t mind, so long as you get your work done!

Generous PTO

Because we pay hourly, we’re able to do some novel things with your PTO plan. From day one you will earn PTO. For each hour you work you get an additional 7.5% that goes into your PTO account. This means that in an average 160 hour month you’ll earn 12 hours of PTO. And, because this is calculated based on the number of hours you work, the more you work, the more you get in PTO. You can take your PTO whenever you want or you can collect it. PTO time never expires. We quite literally put this time in the bank for you. You can collect PTO for your entire career with Alagad. And, when you leave you’ll get any left over time in a check. You can also take PTO without actually taking time off. So, if you have some time built up and you can cash out some of that time to buy gifts during the holiday season, or for any other reason. Also, one of the stranger things we do here is that we do not offer any holiday days off. These are already factored into your PTO. Really, we’re not being so presumptuous as to assume you want to take particular days off. If you’d rather not take Labor Day off, we won’t make you. But if you would like to take, say, your birthday off, you can! It’s up to you.

Health Insurance and Big Company Benefits

Any small business owner can tell you that paying for Health Insurance is a huge burden. However, Alagad not only offers insurance, we chip in $200 a month if you’re single and $400 if you’re married. For a single person this equates to full coverage. A married person would expect to pay about $200 a month on their own. We also have numerous other benefits like Flex Spending Accounts, college savings plans and even adoption assistance. In the future I plan to continue improving or benefits plans. Next year I expect we’ll add a 401k plan and possibly full coverage of health insurance. (No promises yet!)

Important Instructions on How to Apply for this Job

If you want to work for Alagad, please put together a nice cover letter and resume and send it to me at dhughes@alagad.com. In your cover letter please describe why you’re a good match for this job and why we should hire you.

Because I’m nice, I’ll give you a tip on applying for a job with Alagad: I tend to give a lot more weight to your cover letter than your resume. Make your case in your cover letter. Finally, and this is important, please include the word “llama” in your email subject. Seriously. If you don’t include it, I won’t review your resume. Bonus points will be given for creativity!

A Little Slice of Alagad Life

Starting at about 8am today, some members of the Alagad team started receiving, shall we say, subtle reminders to blog. You see, I’m trying to institute a new policy here to have everyone blog at least once a week, with me blogging twice a week. The problem is, as much we we all know it’s good for us (and for you), it’s easy to let blogging take second stage to paying work.

To encourage people to blog, I recently assigned a blog-day to everyone here. I’m supposed to blog Monday and Thursday. Jeff, Layne, Scott and Jared are assigned to Monday, Tuesday, Wednesday and Thursday, respectively. To make sure people remember to blog I made a habit of sending harassing IMs to people encouraging them to blog. This was more effective than doing nothing, but had one slight downfall: I had to remember to remind people.

Last night I was thinking about this problem and though, what the heck, I’ll automate it! As it were, we already have the infrastructure in place to facilitate 90% of this process. We have a project management system we built that already makes use of the XMPP Event Gateway that ships with ColdFusion. We used the gateway to create an IM bot which many of us use to track time against tasks on our various projects. (This time tracking information feeds into our project management system which ultimately feeds QuickBooks and drives our invoicing and reporting. Let me know if you want to hear more about this process and maybe I’ll blog on that as well.)

So, we already had a system to send IM messages to Alagad employees. We also have the blog, which conveniently has an RSS feed that includes the email address for the person who wrote the entry. All I had to do was create a service which first pulled the Alagad.com RSS feed and parsed it to find out the last time any given person blogged.

Next, I had to know what day a user was assigned to blog. For that, I created a new table in my database called UserBlogDay, and stored a userId and the user’s blog-day. By referencing this object in my Reactor config, I was able to use Model-Glue scaffolding to generate the user interface which I then tweaked to perfection.

By cross referencing what day a person was supposed to blog and the last time they blogged I can figure out if the user is overdue to blog. In the case that they are due to blog I then use the same event gateway used by the time tracker IM bot to send them a random nagging IM message.

I set up a scheduled task, which is actually created by the reminder service when it’s instantiated, to run the reminder process every hour. But, I didn’t want to be rude and overbearing. (Well, not that overbearing!) I decided to only have this remind people to blog between 7am and 6pm. The nice thing is, because of the time tracker, I’m already tracking each employee’s time zone and I could reuse functionality to get the time in that user’s locale and only remind them when it’s reasonable.

The whole thing is wired together using ColdSpring. In fact, the messages that can be sent are configured via ColdSpring, though perhaps I should put them into a database table and scaffold an interface to create new nags.

Finally, the entire Project Management system, now complete with a blog-reminder nagging system, is deployed by Ant. We use my CFAnt project to check the application out from subversion, configure it for production, create the data source, enable trusted cache, regenerate all Reactor objects, and more. The whole modification to the project management system only took about 3 or 4 hours to implement and roll out! So, this is a little slice of how we do things at Alagad. It gives you a little peak into our culture as well as how we work! Today, I personally received about 9 reminders to blog! So fine, here’s my blog entry!

Scheming on Schema -or- The Great DTD Debate

As Jeff has written lately we here at Alagad have been working on an Object Management System (OMS) for one of our clients. In the OMS we use XML to to define the database, objects, and (hopefully sometime soon) the views. While I am not that well versed in the intricacies of OO development, I am very well versed in tagged meta-languages. Specifically SGML. I know, it’s a blast from the past but almost everything we do is based on it so I figured I should mention it.

During my career I have written hundreds of DTD’s and the accompanying output specs. I have taught classes on document analysis and DTD authoring. I mention this because my first thought was to use DTD for the XML in our OMS. Clearly it was the most expedient way of defining the XML for me and it gave the opportunity to get back to some of my roots. I had forgotten how much I enjoy analyzing and defining data structures.

Well, for the first portion of the OMS DTD has worked just fine. As you’ve probably guessed, we are now running into some of DTD’s limitations. Custom data typing, namespace and compatibility with other XML technologies are amongst the limitations to which I refer. While most of these limitations can be overcome with creative element, entity, and attribute declarations, the complexity and usability of the DTD starts to make the XML suffer.

Identifying and describing the XML for the objects (DAO, IBO, AdminService, etc…) was relatively easy.There are only so many different elements to define. As we move forward and begin trying to define views, the complexity level of the DTD skyrockets. Trying define every possible, allowable and desirable aspect of a view is daunting. We have already had several instances where we have had to deal with limitations that have forced us to alter our approach. Elements can become many and deeply nested and attribute lists can become very long. These factors contribute to making the XML that much more difficult to write and read.

Enter Schema. Yes, I know it has been around for a while but I have never had a reason to use it. Or, at the very least, not a good enough reason. I think I may now have that reason but making the jump will require a bit of learning and lot of time spent writing… I think.

I have read all the usual “DTD vs. Schema” articles, posts, etc… and I think we need to move in the Schema direction. I am looking for feedback from y’all with compelling arguments for or against this proposition. Is the complexity/learning curve of Schema outweighed by the potential complexity/limitations of DTD in this argument? Should we even bring RELAX NG into the conversation?

Help me out here folks. I look forward to your input.

Until next time.

Tag Cloud