Category: Programming

Episode 2: Meet, Eat, and Learn!


On this episode of the podcast Script discusses conferences in general and his recent trip to NCDevCon in particular.  He also has a great interview with Ben Nadel (@BenNadel)  who has a very popular blog on Coldfusion and Angular programming.


  • NCDevCon– An awesome development conference in North Carolina.
  • – Ben Nadel’s blog with lots of great coding help as well as a jobs board and pictures of a virtual Who’s Who of the community.




Welcome to the second episode of the Wake Up with Script Van Winkle podcast!  My name is Script  Van Winkle, but my friends call me… only when they need something.

Now when you are trying to play catch up with the programming world, like I am, one really great way to do that is to attend one of the dozens if not hundreds of programming conferences put on each and every year. But how do you pick one? How do you afford to go? And just what the heck happens at one of these puppies?

By sheer coincidence, would you happen to believe, I just got back from an awesome conference last weekend in North Carolina.  So I might be persuaded to talk about some of what went on there.  And as a treat, I also caught up with Ben Nadel, who runs a pretty popular blog for those who program in ColdFusion or Node.js., so stick around for a sweet interview with him.

Ok.  So Webster’s defines a conference as “a formal meeting in which many people gather in order to talk about ideas or problems related to a particular topic (such as medicine or business) usually for several days.

Now I have no flipping clue why people insist on starting education discourses with a definition from Webster, nor why Emmanuel Lewis is considered such an expert in etymology. Yeah, that’s a real term there Junior Developer, look it up.

So last weekend I attended NCDevCon, an amazing developer conference in Raleigh, NC.  Now in its ninth year, this conference is held on the campus of NC State.  It was started and run by the Triangle Area ColdFusion User Group, but while there is certainly some ColdFusion specific content among its sessions, it covers a lot of other topics including Javascript, Nativescript, Mobile Development, CSS, database, testing, continuous integration….you get the picture. A wide swath of topics.

While conferences vary of course, most start off with a general session. This is where all the attendees gather in one big room, hear some housekeeping announcements and usually a keynote speech.  In the case of NCDevCon this is almost always a talk from their longtime sponsor Adobe.  Usually Adobe is giving a roadmap to the future of one of their products, usually ColdFusion.  This year though, Elisha Dvorak, Adobe’s ColdFusion evangelist, actually started off the talk by discussing microservices.  While not brand new, microservices is kind of the hot buzzword right now.  

Essentially, the microservice architecture is one in which you break up tasks in your application into smaller, logical, completely independent applications or services, which take input via an API (usually through REST protocols), and return data usually through JSON.  These services should be entirely stateless so that given the same input, they should return the same output.  And since they use network protocols in access, they should be completely platform independent, meaning each and every service could be written in an entirely different language and they should still all be able to work together.,Now, if that didn’t make any sense to you, don’t worry. I plan to cover microservices on an upcoming episode, because I do like the concept and am working on learning more about them.

Now Elishia’s talk did of course eventually divert to talking about current and future versions of ColdFusion. Personally, I am cool with that.  Even if you aren’t using CF or work at a company that is still stuck four versions behind, its still cool to see what they have elected to focus on in the future.

Now I did hear a couple of grumpy gusses complaining about the talk being too salesy.  But those same dudes didn’t seem to be complaining much when they were picking up their sweet FREE Adobe water bottles. And they certainly weren’t complaining when they were eating and imbibing at the Adobe sponsored after party. I’m just saying.  Sponsors help make conferences go. If it means you have to listen to a pitch every now and then who cares.  Get over it!  

After the general sessions, the breakout sessions usually begin,. Now a lot of conferences organize them into tracks, meaning that they have the schedule set up so that you can stick with one topic area should you want. For example, they may have a back-end track, a front-end track, and a mobile track.  At NCDevCon this year they didn’t have any definable tracks, but I figure that is because they had such a variety of topics to choose from.

For someone trying to play catch up, a conference like this offers a great opportunity to get schooled across the realm of programming.  Of course we are talking, in this case anyway, about an  hour a topic. It’s hardly enough to time to truly LEARN everything, but it definitely gives you a chance to wrap your arms around it and gives you a starting point for further exploration.

Case in point, there were a handful of sessions on CSS.  I hate CSS! Ok, I don’t hate it. And I do work with it in my projects obviously.  But sometimes when you are trying to nail down a look or a font, or size something to wrap it the right way, it gets flippin’ maddening!

On day 1, the first and last sessions I chose involved CSS. The first was actually a talk on how to convert desktop apps to mobile by Jessica Kennedy.  Jessica, unlike me, is a HUGE fan of CSS!  I sat in amazement as she showed some tricks that she recommends for being able to manage both a desktop and mobile application.  She won me over.   I actually started to get excited about the possibilities. I really need to revisit CSS. It looks like a blast!.

The last CSS talk I saw that day really showed how to press the boundaries of CSS. It was given by Brandon Kennedy, who as it turns out is very happily related to Jessica. Brandon and his chill preso showed what just a few lines of code can do to make sites come alive. Most of it was way over my head, but definitely something I will explore a lot more!  I am looking at CSS in a whole new light. And  I owe the transition of my opinion to the bold style of the animated couple……see what I did there?

Beyond the learning of course is the networking. Whether or not you are looking for future opportunities like I was, you  should always take the time to talk to other attendees. Or, if you are shy like me and don’t know how to start a conversation, just rudely insert yourself in an ongoing one and smile and nod a lot.  They may think you are weird, but keep those ears open and you may just learn something.

Now conferences generally are not cheap.  Most assume you are going to have your employer pony up the dough for it. But more and more companies are running on leaner and leaner budgets these days, so that is not always an option. One of the things I love about NCDevCon is its affordability. Its tickets this year were only $200 bucks, and I believe it was half that for the Early Bird registration.  Now I had to go on my own dime this year and wondered if I would feel I got my money’s worth. I did ten times over!  Well worth the price!

So to bring an end to this seemingly endless diatribe, let me simply say this. If you are trying to keep up with technology, keep pace with the industry, and feel out potential opportunities for future growth….conference it baby!  Find a local one or one in a place you would love to travel to  (like Vegas or something). But take the time and money to go. You will learn a lot, feel more connected to the profession, make new contacts who could be useful resources, and, if it’s anything like NCDevCon, enjoy some really amazing food!.

Now don’t go away….we’ve got a great interview with one cool dude…come up after this.

(BEGIN Fauxmercial: “Progeny.js”)











(End Fauxmercial)

(Interview with Ben Nadel)


I’m walking around NCDevCon here and you are not going to believe who I ran into. We’re talking the man, the myth, the legend, Ben Nadel himself. I’m telling you, if you guys don’t know who Ben Nadel is, welcome to ColdFusion programming because you’ve obviously been doing it for only two days. I’m telling you, if you ever, ever have a problem and you Google it, you are going to end up on Ben’s site. If you haven’t done that, good luck to you there. I guess the first question Ben, welcome by the way.

Ben Nadel:

Thank you, great to meet you, sir.


The first question I got to say is do you go looking for trouble or does it just find you?

Ben Nadel:

I’ve been very happy to come across a lot of trouble in my daily work. I just try to write about it as best I can and share solutions to the hurdles that I have fallen over and hurt myself on. I’m just a lucky man in that sense.


How long ago did you start all this?

Ben Nadel:

I’ve been blogging since 2006. It just started out as something … I don’t even remember how I started. I was just excited to learn. I love learning. It’s like I get up in the morning and I’m excited to learn. I’m excited when I get to try new things at work. I’m excited when things are difficult because it means something new to learn, something new to write about. It sort of just took a life of its own at some point and it became … Sometimes it’s a passion and sometimes it feels like a job. I get up in the morning and I do it. I just try to keep the momentum going. It’s been 10 years now, 2016.


I’ve always said for all the work you saved every programmer out there owes you two, three drinks, me included.

Ben Nadel:

I appreciate that. I’m still shocked when people say that. When people come up to me and they’re like, “I want to thank you. I read your website.” I’m blown away. I’m still surprised anytime anyone even noticed who I am.


That’s absolutely awesome. We know that for many years you were working on ColdFusion, but tell everyone what you’re working with now.

Ben Nadel:

We have teams that are more specialized doing what I do, but because I’ve been with my company for so long, I have a lot of tribal and historical knowledge. I can jump around and help fix bugs, help work on database bottlenecks, help work on code. I work in ColdFusion. I work in Angular 1.x primarily. I try to jump over and do a little React with the teams that do React. I work with MySQL. I do a little bit of Redis, a little bit of MongoDB. Just a little bit all over the place.


Showing off again, aren’t you?

Ben Nadel:

No, trust me. If you saw me doing any of these things, it would not be showing off. I can show off maybe in ColdFusion and some Javascript. Everything else is like just trying to not make it break.


One of the other things about your blog, I just hit you up for this, is you have been taking photos of people at conferences over the years. How did that all get started?

Ben Nadel:

You know what it is too is I am by nature a very shy person. The photos also help push me out of my own comfort zone. I feel like I got to psyche myself up to talk to people. I got to psyche myself up to ask for a photo at this point even all these years later. Part of it is how I try to grow as a person and part of it is, the fun part of it is community building. It’s just great. I love doing it.


You’re not even going to admit that it’s really about hit counts? I ain’t going to tell you how many times I’ve refreshed that screen just trying to get an idea of who’s who in the community.

Ben Nadel:

I will not fight any collateral benefit that comes from it, sir, absolutely not.


Just so you know, for all the listeners out there, if you want to see what I look like, I just got a great picture with him, which he’s already agreed he’s going to leave up as the primary picture for the next three weeks. Maybe, maybe not, we’ll see how that one works out. The other thing that you have on your blog, which is awesome, totally awesome, is the jobs board. I may or may not have gotten a few interviews that way. I refuse to talk about that, but I’m just going to ask how did that come about?

Ben Nadel:

I was charging I think like $199 at some point. I think I started charging $99. I got to a point in my life where I wanted to start giving back more, consciously, so I started to donate a portion of each job post to Kiva, which is a crowd-source loan site. That almost became more interesting to me than the job posts themselves. I finally just lowered the price to whatever covers the Kiva loan. I think now a job posting’s like $29. That just covers the $25, plus the processing fee to Kiva. It’s just exciting for me to be able to help the community in whatever tiny way I can, and then funnel that back into kind of a greater sense of the common good.


Has anybody ever thanked you for getting them a job that way?

Ben Nadel:

Yeah, a couple times. I almost sort of think it’s never helping, but I have a couple of times in person, people have said thank you. A couple of people have emailed me and said they’ve gotten it. It’s a low traffic. It doesn’t have a lot of posts typically, but occasionally it gets lucky. I feel really good about that actually.


I for one, absolutely thank you. I appreciate that. Ben, it was a pleasure to meet you. If you guys haven’t checked out his blog, it’s Believe me, you’ve probably found it by Googling it, but just check it out. Hang in there. Follow him on Twitter too and see the great adventures of his dog. What’s the dog’s name?

Ben Nadel:



Dog’s Lucy, vacation out in nice exotic places I see.

Ben Nadel:

Any opportunity to take the dog to the beach makes me happy. Chris, it’s wonderful to meet you. I really appreciate the opportunity to sit down and talk.


Thanks a lot, Ben. Take care.

So that wraps episode 2 of Wake Up! With Script Van Winkle. I want to personally thank Ben Nadel for taking the time to sit down and talk with the weird unknown dude shoving an iPhone in his face.  Seriously though I had wanted to meet Ben for a long time and he did not disappoint.  As you could hear a truly down to earth guy with positive attitude and pretty good programming chops to boot.

And thanks to the organizers of NCDevCon for graciously taking my money…….and giving me an experience back worth so much more.  The organizers and volunteers here are the best!  And, in case I didn’t mention it, all of the talks will be online shortly. So if you were there and missed a few sessions or couldn’t make the event at all, it’s all there for you to check out! Just visit

Now, this was kind of a special episode. I’m going to get more into technical things in the next few episodes. So if you’ve got questions or topics you would like me to cover, drop me a line at or find me on Twitter @ScriptVanWinkle.  You can subscribe to the podcast in iTunes, Google Play,  or on Stitcher. You can comment on this episode, see blog posts and find more info at

Thanks for listening and I’ll talk to you next time.

ORM / CSS – #NCDevCon Live Blog #3


NCDevCon North Carolina’s Premier Web & Mobile Conference

Apparently my afternoon sessions were all about three letter abbreviations.  Kicked it off with the ORM talk by Masha Edeler.  I’ve played with ORM, thought I knew ORM, but learned things I didn’t know! I especially learned about creating properties which were subsets of  a table and other properties that can be defined by a simple SQL statement, I also learned more about HQL I didn’t know. Nice job. Check it out online when available.

Wrapped up the learning day with  Thinking Outside the Box With CSS  by Brandon Kennedy. CSS is definitely cool!  But some of this stuff can make my head hurt!  Brandon demoed a ton of cool animations and showed how simple they can be!  I did feel better about myself when he talked about using and studying the Animate.css library.  I discuss my experiment with it in Episode 1: The Wind Up and the Pitch! Playing with HTML 5 Animation of my podcast.  HINT HINT!  Check it out!

Hey!  It’s After Party time!  Find me! I need people to help me record the new podcast intro!  Look for the dork in the red Mickey shirt!  Be nice to him!  I’m sensitive!

Cookies and Treats! – #NCDEVCON – Live Blog 2


NCDevCon North Carolina’s Premier Web & Mobile Conference

The term “Cookies” in development of course has multiple meanings.  But at #NCDECVON during the break sponsored by Strongloop, cookies were plenty and sweet!  Delicious cookie sandwiches filled with coma inducing filling.  Sorry for those speaking afterward….I forsee a lot of snoring!  Don’t take it personally!

Another “treat” was Raymond Camden’s talk on APIs….well…except he called an audible. Instead he tested out another talk he is working on about changes in programming.  Nostalgic man!  Nostalgic!  He even showed a program printed in “Family Computing” magazine in the early 80’s I believe.  Man I felt old!  I remember putting the program into my Apple II compat. computer (Franklin Ace 1000) and watching it works. Thanks for making me feel old Raymond!  Seriously!  Funny and inspiring talk though.

I also caught Matthew Eash’s talk on Node.js, in particular the Express framework.  Still can’t say I fully understand it, but it definitely started to make sense to me.  Pretty flipping cool for sure!

Ok, back to business. Hope the caffeine kicked in.  Getting ready for Less Hate, More Love With Coldfusion ORM  by Masha Edelen.  Met her earlier and am looking forward to hearing talk on the topic. Let you know how it goes!

Live(ish) Blogging – #NCDEVCON – Report 1


NCDevCon North Carolina’s Premier Web & Mobile Conference

Ok. So it’s not exactly LIVE blogging (as I am sitting here after an AMAZING BBQ meal)  stealing power and getting ready for the next session. But already, #NCDEVCON has proved to be a great conference!

I have always loved the clear as a bell tape lines helping streamline the checkin process (you guys should patent it).  Then things kicked off with a session on API’s by Elisha Dvorak from Adobe. Elisha talked about the future trends of apis and microservices and how ColdFusion is positioning itself to make those easier to handle.  It was 50,000 ft look at apis for sure but I left knowing more about an area I do find engaging.

Session breakouts after that. I can, of course, only cover those I actually attended.  For me, I kicked up Small Screens, Big Rewards! The Experience of Converting Desktop Websites to Mobile by Jessica Kennedy.  She was fun, informative and a great evangelist for mobile and CSS. I am one of those many developers that are driven mad by CSS…..hate it!  But Jessica really turned my thinking on it.  Looking how seamlessly and quickly it seemed she could make things rearrange, resize, and realign with a few simple code changes was awesome!  I left really jazzed about CSS!

My next session was one put on by Raymond Camden  called Everything They Didn’t Tell You About Hybrid Development.  Always informative and always entertaining, talks by Raymond are usually no-miss.  I learned a lot as he described some dos and don’t with regard to using Cordova to do mobile app development. He spent a great deal of time on the your persistance options (Indexed DB, WebSQL, SQLLite, etc,)  He also mentioned some great tools to use as well.  Kind of wished I had experienced using Cordova before attending but hey, I’ll keep the info tucked away until I need it.

And then lunch!  Did I mention the Carolina pulled pork BBQ and mouth-watering BBQ sauce?  And the baked beans?  Take it from a guy who thinks baked beans is the only side a meal should ever have….they were killer!!!

Well, ready to get my Node on…..Build Your Backend in Node.js  by Matthew Eash. That is assuming I can get my backend up and moving after that lunch!

Getting Dumped While Using MXUnit

With all my real world experience getting dumped, I never thought it could ever be a good thing. But in programming, getting dumped, more specifically, dumping variables, is immensely useful when debugging. I use it all the time when writing code.

But having lately been playing more and more with unit testing, specifically using MXUnit in Eclipse, debugging errors through unit testing seemed a bit more problematic.  I could put dumps in my CFCs but that output would never make it to my test case results. How was I expected to debug that way.

Then I had an idea. Stop me if you heard this one.  Instead of using “writeDump”, I raised an error. I used the throw statement. For the error type I put the name of the variable. For the message I put the value of the variable:  For instance, I put:

throw(message=userID, type=”User ID”);

When I run my unit test in Eclipse in my results I see “User ID: 84756”. Voila!  One caveat  however, and it is a big one, it only works with scalar values.  Figuring out how to dump structures and arrays will be my next task.

Always learning….always growing.

OhRM! Why Aren’t You Updating?

One of the great (and probably terrible) things about having so much to learn in the development world is that I often find myself trying to learn several things at the same time.  For example, late last week I began playing with the jQGrid plug-in. But I had to build back-end support for it, so I did that in ColdBox (which I also have been playing with).

Things went great on pulling the data and pushing it to the plug-in.  But things got more complicated when I had to build the back-end methods for processing the updates from jQGrid.  Building the SQL statements was a challenge. In the back of my mind I heard a voice screaming “ORM” (Object Relational Mapping), but while I have flirted with ORM (by that I mean watched one or two online presentations about it), I hadn’t taken the plunge.  So did I really want to add a third variable to this R&D?  I resisted as long as I could…but going non-ORM with this was getting ridiculous, especially since I was building a back-end to handle just about any table we need it to.  No doubt about it. ORM was the way to go!

So I took the plunge.  First hurdle….how can I use ORM on existing tables without running the risk of it modifying those table structures. A quick Google search brought me the answer (on Ben Nadel’s Blog no less…..a lot of CF developers need to buy him drinks for the amount of time his posts save).  Simply adding:

this.ormSettings = { dbCreate = “none”}

to the application.cfc file solves that problem.  It prevents ORM from making structure changes.  Great!  Now I can move on!

Fetching data with ORM was a breeze!  It also allowed me to eliminate several private methods in my CFC.  Sweet!  And look.  Updating information is as easy as loading an entity, changing its properties, and saving it back out.  Perfect….except….the data in the DB table didn’t change.

What was I doing wrong? I scoured numerous blog posts on ORM, tried everything from saving, to not saving, to flushing….no joy! I spent a good 6 hours or more trying numerous things and cursing this wretched beast known as ORM!!!!

Then I found the problem.  Because I was building this back-end to handle any table we need it to, having to know the names of the setters and getters was troublesome.  In ORM, those are created for you and are named based on the property name. For instance, I have a title field. So the setter is setTitle() and the getter is getTitle(). Simple enough, but I won’t know what fields my entity has until run-time since it will depend on what entity is being requested.  As an aside, would it not make more sense to autogenerate a function called “setProperty” and pass it the property name and value, and a function called “getProperty” and pass it the property name and value, than to generate two functions for each and every property in the entity?  Would love to know why its done that way.

However, one way around this I saw was just to set the property directly on the entity. So if my entity’s name was oTest, I could set the title by saying “oTest.title = “This is a test”.   Basically what is happening is, ColdFusion implicitly calls the correct setter based on the property name…but only  if you put the statement

this.invokeImplicitAccessor = true;

into your application.cfc.  What a great solution!

But what confused me is I had done all of that and still it was not updating my DB.  Hours went by. Finally I tried a test using the setter directly. The database changed.  Looking at the dump of my entity showed it having all the properties I set and a property called “properties” that also had each one of the properties but with the values pulled from the DB. That should have been my clue.  The invokeImplictAccessor setting was failing. It was not giving me an error. It just wasn’t working.   The culprit….support for invokeImplicitAccessor started in CF10. I am developing on CF9.  Grrrr! Not giving up on ORM…just have to go find a workaround now. Suggestions welcomed.

How Many Installs Does Development Take?

About two weeks back, in the middle of a development crunch of course, the hard drive on my work laptop began gently letting me know it was not long for this world.  Without hesitation, I rushed my machine to our IT department for a hard drive transplant.  It proved to be more difficult than first anticipated, and so I was given a loaner laptop.

First day or so I did a lot of online education, not wanting to install anything since it should have only been for a day.  But the problem became increasingly difficult, and ultimately terminal.  The loaner was now going to be my laptop for the next few weeks.

Development couldn’t wait!  I had to get the laptop set up for dev work. No sweat. Code is all committed to source control. Just download my preferred IDE, check out the branch I am working on and away we go!

Hmmm….IDE has changed versions since I first installed it. This version is a little different. Ah…I’ll adjust. Oh yeah, source control was done through a plug-in to the IDE…but which one?  Ok…there are a few….must have been this one!  Nope…but…this might be better.  Ok…code checked out! Let’s develop!

Oh…didn’t set up local server.  I’ve got to do that.  Ok. That’s working.  But pages aren’t serving right. Oh yeah. Need to grab developer version of ColdFusion.  Installed…but don’t have the list of mappings I need.  Bug other team members for mappings. Still not quite right. Oh yeah…forgot custom tag mappings are in two places. All good….no…not quite yet.  A few other settings, and boom!  CF is now working!  Now to develop!

Drat! Homepage works but the other pages are failing.  Oh yeah!  URL rewrites. Need to install rewriter. Grab file of rewrites from repo. Voila. Ready to develop. On to first ticket!

Oops. Ticket involves needing to access the database. Need to reinstall SQL Developer tools.  What?  Can’t get to the install discs today? Oh man!  Ok…what was that freeware tool I used a few years back….frog or something….oh yeah. I remember.  It’s not free anymore?  Figures. I’ll try it out anyway, maybe its better.  Hmm, wonder why they needed my phone number. (five minutes later)  “Hello….yes I did just install the froggie DB thing….like JUST installed it. Your from where? You own the program?  Wait…I thought you made computers…not software?  What am I planning on doing with it? I just thought I would try it out.” (Leaving out that I did so because I was in a bind). “Sure…I’ll call you if I decide to purchase the product at the end of the trial”  (Have a nice life…doubt you will hear from me again).

Oh…a couple of other IDE plug-ins I forgot! I haven’t even reinstalled my VMs, or the framework I am playing with, or the cool open source browser ([ ]) I keep seeing plugged in my Twitter feed.  Oh…and my machine only has IE. So I have some browsers and their associated plug-ins to download. Really. “HOW MANY INSTALLS DOES IT TAKE TO DO SIMPLE DEVELOPMENT?”

Anyone remember when all it took was notepad and a copy of NCSA Mosaic?

Public vs. Private Functions: When is it just redundancy?

A couple of years ago when I first delved into object-oriented programming I was reading a lot of different resources.  One spent a great deal of time describing “public” methods vs. “private” methods.  While I was a little confused at first, I quickly understood that “public” methods were ones that could be accessed from outside of the package (in my case, CFC), and that “private” methods weren’t visible to anything but other methods within the same package (and probably the NSA).  In other words…the actions that take place “behind closed doors”.

This same resource went on to emphasize that best practices dictate that your public methods should contain virtually none of your business logic. In fact, they recommended that your public methods be nothing more than pass-throughs that send the request information on to a similarly named private method.  For example, if your CFC has a method named “login” that is passed the username and password, the only thing that method will do is call a private method named “_login” (note the convention of prefacing private functions with an underscore), and pass it the username and password. Of course, if the private method returns a value the public method will capture the private method’s return value and echo it back to the original caller.

On the whole, this process makes sense to me and indeed is exactly how I have written my CFCs since.  But I am often finding that my CFCs seem to be twice as long as they should be. If I have four public methods, then I have at least four private methods.  And since I love to comment the heck out of everything, this can lead to long CFCs for fairly simple tasks.

So this has left me wondering what you as a developer do.  Is what I am doing “best practice” or is it just bloating my CFCs? Is there a better approach to this that offers the security of private methods without overloading the file with redundant comments and code? I would appreciate comments and suggestions.

As a side note, I have been wanting to employ this same model in the JS files I write. But I think I must be missing something. I can’t figure out how to make “private” methods in JS. Any insight on this would be great as well.

Still playing catch up….and still learning everyday….and loving every minute of it!

Dropping CFScript Functions into Your JS File

This post is about the cool similarities between Javascript and CF Script in ColdFusion.  But since this is my first post, a little introduction is in order.  I have been a web developer since 1996 and started with ColdFusion in 1998.  But once I got to ColdFusion MX, I got in a rut, lost my passion for programming and pretty much took a nap….a long nap….until about 2011. Boy did I miss a lot!!!  It was like waking up to a whole different world!

What an exciting time to be a developer!  With jQuery and a bazillion other JS libraries, MVC  frameworks, CFScript, mobile development, cool things like node.js  (I hear tell it actually flies little helicopters) and even databases without SQL (who knew that was possible), there is so much to learn!  I want to learn it all! But in the meantime, I hope to share some of what I find with you, both in my day to day work, and in memory dumps of things I have picked up since I awoke.  Feel  free to join me in the journey.

What better  way  to kick off  the Script Van Winkle  blog than with a discussion of script.  Before my nap I had programmed a ton in ColdFusion…but in all tags of course.  I had also programmed often in JavaScript, so that was familiar to me as well.  My first thought when hearing you could now do script in CF was,  of course, “why?”.  It did not make sense to me at first.

Despite being a disorganized mess in my private life, I love organization in my code.  I like it to look neat and easy to read.  I love white space and tabbing lines  to make code more readable.  In playing around with CF Script,  I found it looked more organized.  To me,  it seemed much more readable.   So I got it. I thought I had discovered why CF Script was cool.  It’s easier to read.  All the functions in my new or rewritten CFCs are now in script.

But it turns out there is so much more!  I was working on a project at my day job where, when building the page,  a call is made to a third party image renderer  for a preview image.  I have a function in my CFC (in script of course), that builds the URL to use to call the third party rendering.  It works great!

But we wanted to give the user the opportunity to make changes,  have that image rerender  based on those changes, and to do it without  necessarily having to use our server as a go-between.  So I had to write a JavaScript version of the CFC function that built the URL. This is where it got cool!

I copied the CF Script from that function into my JS file. Did it work right away? Of course not.  But it only took a few little adjustments to get it up and running. I did not have to rewrite the whole thing (and my comments didn’t need to change either).

You can do the same thing…just keep a few things in mind:

  1. Don’t forget, arrays in CF start at 1. In JS they start at 0.  This will likely trip you up at some point. Make sure you adjust any loops to reflect that. This usually entails starting loops at zero rather than one, and often your “less than or equal to” comparison to the length of the object you are iterating over, becomes simply “less than” the length.
  2. Speaking of decision operators, operators  such as  “is less than”, “lt”, “lte”, “gt”, “gte”, “is greater than”, “eq”, “equals”, etc.,  need to be changed to the JavaScript equivalents like “<“,  “<=”,  “>”,  “==”, “===”,  etc.  Make sure you have checked all of your loops for this as well.
  3. Speaking of loops, particularly those of the “for” variety, you can replace the incremental in CF with the JS equivalent. For example: “for (intX = 1; intX LT 3; intX = intX + 1)”, becomes “for (intX = 1; intX < 3; intX ++)”
  4. If you are using ArrayLen or ListLen, or just plain Len in CF, change those to use the “.length” function in JS.  For instance: “ArrayLen(aryItems)” becomes “aryItems.length”.
  5. Functions like “Replace” need to be switched out with JS version.  For example “Replace(strTestString, “saint”, “st.”) in CF becomes “strTestString.replace(“saint”,”st.”)  in JS.  There are a few CF functions that fall into this category.  Just figure that any function that takes a variable name as its first argument in CF probably has to modified.

While the amount of changes necessary will depend on the complexity of your particular function, you will more than likely find that a large percentage of the code is unchanged.  This is especially true if your DOM variables on the client side mirror your variables on the server side.  In my case,  I was dropping the entire object containing the graphics information to the DOM via JSON……but that is another post!

There are many reasons why you should switch to using CF Script, these are but two.  Happy scripting!!!!

© 2018 Script Van Winkle

Theme by Anders NorenUp ↑