Skip to main content
Ben Nadel at InVision In Real Life (IRL) 2019 (Phoenix, AZ) with: David Fraga
Ben Nadel at InVision In Real Life (IRL) 2019 (Phoenix, AZ) with: David Fraga@davidfraga )

Recent Blog Posts by Ben Nadel

Rendering Wrapped Text To A Canvas In JavaScript

By Ben Nadel on

Yesterday, I looked at using the Range class to detect line-breaks in a text-node within the DOM (Document Object Model). Normally, you don't need to think about the line breaks that the user is seeing in the browser. However, I have a use-case in which I need to render said text to a <canvas> element. And, since the <canvas> API has no inherent way to render line-wrapped text, all line-wrapping has to be performed progammatically. As such, I wanted to post a fast-follow demo in which I use the line-break detection from yesterday's demo to render wrapped text to a Canvas element in JavaScript... read more →

Detecting Rendered Line Breaks In A Text Node In JavaScript

By Ben Nadel on

At work, I've been building a way to generate "placeholder" images using a fragment of the DOM (Document Object Model). And, up until now, I've been using the .measureText() method, available on the Canvas 2D rendering context, to programmatically wrap lines-of-text onto a <canvas> element. But, this approach has proven to be a bit "glitchy" on the edges. As such, I wanted to see if I could find a way to detect the rendered line breaks in a text node of the document, regardless of what the text in the markup looked like. Then, I could more easily render the lines of text to the <canvas> element. It turns out, the Range class in JavaScript (well, in the browser) might be exactly what I need... read more →

Working Code Podcast - Episode 88: Documentation, Yay!

By Ben Nadel on
Tags: Podcast

This week on the show, the crew talks about documentation. Yay! As developers, there's no doubt that we all love consuming great documentation - especially for APIs. But, nary a one of us enjoys the process of creating documentation. Except maybe Adam, who's oddly passionate about communication. For the rest of us, however, documenting our choices and our subsequent outcomes feels a bit of a slog. It's never clear when we should be writing documentation; it's never clear what we should be documenting; and, it's never clear just how much detail we need to include. And sometimes, ironically, it seems that the more thoroughly we document a topic, the more likely it is to be misunderstood. So, that's awesome!.. read more →

Updated Thoughts On Validating Data In My Service Layer In ColdFusion

By Ben Nadel on
Tags: ColdFusion

When I was building my proof-of-concept (POC) for feature flags in ColdFusion, I started to work with complex data structures that were far more complex than the flat, relational data that I'm used to working with. As such, I didn't have an good instinct about how to go about validating, sanitizing, and normalizing this data. In an earlier post, I looked at validating complex, nested data structures in ColdFusion; but, validation turns out to only be part of the story - especially in a dynamically-typed, case-insensitive runtime. Now that my POC is published, I wanted to circle back and share my updated thoughts on handling data in my ColdFusion service layer... read more →

Strangler: Building A Feature Flag System In ColdFusion

By Ben Nadel on
Tags: ColdFusion

For the last month-or-so, I've been quiet on this blog. Much of that is, unfortunately, stress-related; but, much of it is also do to a small rabbit-hole that I fell into: Feature Flags. If you've followed this blog for any period of time, you've no doubt seen me rave about feature flags. At work, I use and love LaunchDarkly; but, LaunchDarkly is too expensive for side-projects (such as this blog). As such, I wanted to see if I could create a LaunchDarkly-inspired feature flag system for my own personal ColdFusion projects. I'm calling this proof-of-concept "Strangler" (as in the Strangler pattern)... read more →

Working Code Podcast - Episode 87: Note To Self

By Ben Nadel on
Tags: Podcast

On today's episode, we get to pull up the floor boards and once again peer into the dark, disturbing recesses of my brain: all the random and, frankly, sometimes incoherent chit-cat that I have with myself. Listen to me call B.S. on flaky tests; shake my first at overly-specific CSS selectors; preen about GulpJS builds; pontificate on the ROI (return on investment) of personal growth; and, theorize that building - not buying - can sometimes be the smarter and less bureaucratic move to make... read more →

ColdFusion Alive, Episode 117: Adobe ColdFusion And Lucee CFML Roundtable, Part III

By Ben Nadel on
Tags: ColdFusion

Ask me what I love about ColdFusion and I won't be able stop myself - there's too dang much to discuss! But, thankfully, I'm not the only one afflicted with such a luxurious problem. Which is why Michaela Light, Charlie Arehart, Gert Franz, Mark Drew, and I got together - yet again - to have a round table discussion about ColdFusion (Episode 117) on the ColdFusion Alive podcast... read more →

Working Code Podcast - Episode 86: The Working Code Test

By Ben Nadel on
Tags: Podcast

Twenty-two years ago, Joel Spolsky wrote an article titled, The Joel Test, which outlines 12-steps for evaluating the quality of a software team. At the time, Joel was working with Microsoft, building products that were delivered on CD-ROM. As such, his day-to-day workflow was somewhat different than the kind of work that I do. That said, much of what he had in his 12-point litmus test still holds true! Which I believe is a testament to how fundamental his insights were. This week on the show, we review Joel's list, give each item our personal Yay or Nay, and then add a few requirements of our own... read more →

Working Code Podcast - Episode 85: Shipping Complexity

By Ben Nadel on
Tags: Podcast

The less code you write, the easier it is for people to review, the less likely it is to contain bugs, and the more likely it is to merge cleanly into your main integration branch. The converse of this tends to also be true: the more code you write - particularly within a long-lived feature branch - the harder it is to review and the more likely it is to contain bugs that cause production issues. We all basically hold this to be true; however, that doesn't mean that we can simply choose to do the former. Shipping less complexity is a byproduct of both team and technology constraints. This week on the show, the crew talks about how we try to reduce the complexity of our code-shipping process... read more →

Pretty-Printing JSON Using GSON In Lucee CFML 5.3.9.141

By Ben Nadel on
Tags: ColdFusion

I'm currently working on a proof-of-concept (POC) for a feature flag system in Lucee CFML. And, for my POC data persistence layer, I've been using a simple, flat JSON (JavaScript Object Notation) text file. This works great; but, I found myself wishing that the JSON file was pretty-printed so that I could more easily debug my data persistence algorithms. ColdFusion's native serializeJson() function doesn't have a pretty-print feature; but, I was able to use Google's GSON library to generate pretty-printed JSON output in Lucee CFML 5.3.9.141... read more →

Using Multiple Break Statements In A Single Case Clause In ColdFusion

By Ben Nadel on
Tags: ColdFusion

For the last few weeks, I've been quasi-heads-down, noodling on a workflow that builds-up complex objects using form POSTs in ColdFusion; and, as part of that workflow, I have a switch statement that defines some mutations on the pending-object in question. The other day, my logic was getting a bit complicated and I went to see if I could use multiple break statements within a single case clause. Turn out, this totally works in ColdFusion... read more →

Working Code Podcast - Episode 84: Interview With Jason Henriksen

By Ben Nadel on
Tags: Podcast

This week on the show, we interview Jason Henriksen who works alongside Carol as a Software Architect at Clear Capital. According to Jason, every engineer does some degree of architecture, whether they know it or not. In fact, there's a lot of overlap between what Jason does and what your average web developer does. Which is why he calls his team the "Architecture Support" team. Their goal isn't to hand down edicts and pass out proclamations. Instead, Jason's goal is to build bridges between teams, help identify common pain points, propagate best practices, and lovingly guide the company in the right technical direction... read more →

Using Strict Type Decision Methods In ColdFusion

By Ben Nadel on
Tags: ColdFusion

Historically, one the nicest features of ColdFusion is the fact that it is loosely typed. And, that the language will - in most cases - happily and transparently cast one data type to another in order to get the job done. As the language has continued to modernize, however, some of its loose behaviors can cause unexpected errors. As such, I was proposing yesterday, on the Lucee CFML developer forums, that the language might introduce some Strict decision functions... read more →

Validating Complex, Nested, Dynamic Data Structures In ColdFusion

By Ben Nadel on
Tags: ColdFusion

Last week, I looked at building-up complex objects using form POSTs in ColdFusion. I then took that same technique and used it to create a multi-step form wizard that doesn't require any data persistence. All of that was in service of creating a feature flag system for my blog (see my Tweet). But, building-up a complex object is one thing - validating and persisting that complex object is whole other beast. And, to be honest, I don't have a go-to method for validating complex, nested structures in ColdFusion. As such, I've spent the last week playing around with an approach that I would like to share... read more →

Working Code Podcast - Episode 83: What If You Weren't A Coder?

By Ben Nadel on
Tags: Podcast

We all love writing code. Honestly, here on the show, it's hard for us to imagine doing anything other than building beautiful digital products for our beloved customers. But, as a thought experiment - in these post-pandemic times - the crew wanted to share some of the other professions that could have been. From ice cream truck driver to organic chef to movie theater entrepreneur, we dive into the untapped world of alternate realities... read more →

Building-Up A Complex Objects Using A Multi-Step Form Workflow In ColdFusion

By Ben Nadel on
Tags: ColdFusion

Earlier this week, I looked at using form POST-backs to build up complex objects in ColdFusion. That technique allowed for deeply-nested data to be seamlessly updated using dot-delimited "object paths". My previous demo used a single page to render the form. As a fast-follow, I wanted to break the demo up into a multi-step form workflow in which each step manages only a portion of the complex object... read more →

Working Code Podcast - Episode 82: GitHub Charging For Copilot

By Ben Nadel on
Tags: Podcast

This week on the show, the crew talks about GitHub Copilot. After being in private beta for several months, this "AI pair programmer" is now generally available as a paid product for $10/month or $100/year. But is this something people want to pay for? Will a price put the kibosh on grassroots adoption? Are there pros-and-cons to different pricing models? And, is there ever going to be a world in which I can get past my own fanatical formatting tendencies?.. read more →

Building-Up A Complex Objects Using Form POST-Backs In ColdFusion

By Ben Nadel on
Tags: ColdFusion

Normally, when building forms in ColdFusion, I have simple key-value pairs that map neatly onto individual form fields. Recently, however, I've been working on a form workflow that needs to both construct and populate a complex object before the data can be persisted. To manage this workflow, I'm borrowing an idea from ASP.net wherein the "state" of the page is posted back to the server on each form submission. This "state" can then be acted upon by the ColdFusion server in order to maintain complex data structures across page loads... read more →

Working Code Podcast - Episode 81: Total Randos

By Ben Nadel on
Tags: Podcast

This week on the show, the crew shares some of the random stuff that we've been dealing with at work. Carol is about to submit a PR (Pull Request) that accounts for 8-weeks worth of commits; and, she's already warning her engineers that it's gonna be beefy! I'm wondering if I've been fooling myself into my love of Lucee CFML's "Tag Islands"; or, if there's something fundamentally more enjoyable about the developer ergonomics of the CFQuery tag. And, Tim's been working on remaining PCI (Payment Card Industry) compliant by scrubbing credit card numbers out of his customer's "name" fields; because, as it turns out, customers will jam a credit card number into just about any form field that they find!.. read more →

Using An Array To Power Weighted Distributions In Lucee CFML 5.3.8.201

By Ben Nadel on
Tags: ColdFusion

Lately, I've been working on some code that needs to randomly assign a value to a request. But, the "randomness" isn't entirely random: the set values needs to be assigned using a weighted distribution. Meaning, over a period of time, each value should be "randomly assigned" a limited percentage of the time. I'm sure there are fancy / mathy ways to do this; but, I've found that pre-calculating an array of repeated values makes the value-selection process simple in Lucee CFML 5.3.8.201... read more →

Namespacing Components With Per-Application Mappings In ColdFusion

By Ben Nadel on
Tags: ColdFusion

In my ColdFusion applications, I use a lot of components. But, these components are, for the most part, application-specific and live seamlessly alongside my application's custom mappings. Recently, however, I've been thinking about writing a "module" (ie, a set of related components) that I might want to use in multiple applications. And, it wasn't immediately obvious to me how I might define my ColdFusion per-application mappings in order to avoid conflicts with an application's existing component tree. As such, I wanted to experiment with using per-application mappings to create "namespaces" for shared ColdFusion components... read more →

Looking At The Performance Overhead Of A Read-Only Lock In Lucee CFML 5.3.8.201

By Ben Nadel on
Tags: ColdFusion

In yesterday's post, I demonstrated that iterating over shared Structs and Arrays is thread-safe in ColdFusion; assuming, of course, that the access is read-only. But, what if I need to occasionally mutate the shared data? In that case, I'd have to acquire an exclusive lock some of the time; which, in turn, means that I'd have to acquire a read-only lock most of the time. This got me thinking about the performance overhead of a read-only lock in Lucee CFML 5.3.8.201... read more →

Updating My Mental Model For Shared Array / Struct Iteration In ColdFusion

By Ben Nadel on
Tags: ColdFusion

In the very early days of ColdFusion, it was considered a "Best Practice" to synchronize access to all shared data structures. Meaning, to single-thread the access in order to avoid race conditions. Over time, this practice became much more nuanced; and, more of the native data types within ColdFusion became synchronized by default. Meaning, they were being made thread-safe internally. I believe that my mental model for iteration over shared data structures is outdated. As such, I wanted to run some parallel iterations in Adobe ColdFusion 2021 and Lucee CFML 5.3.8.201... read more →

Working Code Podcast - Episode 80: Other Duties As Assigned

By Ben Nadel on
Tags: Podcast

In each role, there are the responsibilities that get listed on the job board; and then, there's all the random stuff that they ask you do to once you show up. On today's show, the crew discusses the latter: those strange and wondrous "extras" that sometimes get rolled-up into an honest day's work. Topics include: buying nipple cream, picking up cigarette butts, cleaning bathrooms, taking out trash, driving to remote server locations, restocking photocopiers, and - perhaps worst of all - getting pushed into Sales... read more →

Considering A Stale-While-Revalidate Pattern To Caching In ColdFusion

By Ben Nadel on
Tags: ColdFusion

In a recent episode of Syntax.fm, Scott and Wes discussed HTTP caching headers. From their discussion, I learned that there is am experimental value called, stale-while-revalidate. And, while this post isn't about HTTP caching, their discussion got me thinking about different ways in which I might manage a server-side cache of data that needs to be kept in-sync with a remote data source. I wanted to do some noodling of what a "stale while revalidate" workflow might look like in ColdFusion... read more →

Playing With Java Pattern's Named Capture Groups In ColdFusion

By Ben Nadel on
Tags: ColdFusion

In yesterday's post on the new jreExtract() method in JRegEx.cfc, I was aliasing the Regular Expression (RegEx) capture groups with human-friendly labels as part of my demo-output. This reminded me that the Java Pattern class added named capture groups in Java 7 (circa 2010); and, I've yet to ever try them out. As such, I thought it was high-time to give named capture groups a try in ColdFusion... read more →

Adding jreExtract() To Pluck Captured Groups Using Regular Expressions In ColdFusion

By Ben Nadel on
Tags: ColdFusion

I love Regular Expressions. I use them probably every day in some capacity. And, I've loved having my JRegEx.cfc project to simplify many pattern-based interactions. Today, I'm adding one more tool to that toolbox: jreExtract(). The jreExtract() method matches a Java Regular Expression against an input String and returns a Struct of the captured groups. Sometimes, I want to use a single pattern-match to pluck-out parts of a string in ColdFusion... read more →

ColdFusion Alive, Episode 115: Adobe ColdFusion And Lucee CFML Roundtable, Part II

By Ben Nadel on
Tags: ColdFusion

A few weeks ago, I appeared on episode 113 of the ColdFusion Alive podcast with Michaela Light, Charlie Arehart, Gert Franz, and Mark Drew. In that episode, we had so much fun talking about how wonderful modern ColdFusion is that we decided to have ourselves a part II: Episode 115. In this fast-follow, we talk about the strengths and the weakness of the ColdFusion and Support communities at large... read more →

Ask Ben: Extending A ColdFusion Session On A Long-Lived Page

By Ben Nadel on

Hi Ben, I am trying to learn ColdFusion and have a question. I hope you can help me. I have an application where a user logs into a portal. Session variables are set to time out in 30 mins. But, is it possible to extend the session if the user keeps using the page. For the application, even if the user is moving the page up and down and making some interaction with the page, the session still expires. Thank you so much in advance.!.. read more →

Working Code Podcast - Episode 79: Potluck 5

By Ben Nadel on
Tags: Podcast

This week on the show, Adam and I examine a variety of random topics: Adam loves watching conference videos on YouTube; I am feeling terribly insecure about falling behind in the field of web development; neither of us can believe that Elon Musk is forcing his employees back into the office; and, how is it possible that some people seem have so much free time - what the heck is their secret?! I'm constantly struggling to find time to do all the things that I would like to do... read more →