Skip to main content
Ben Nadel at cf.Objective() 2014 (Bloomington, MN) with: Jonathan Dowdle
Ben Nadel at cf.Objective() 2014 (Bloomington, MN) with: Jonathan Dowdle ( @jdowdle )

Recent Blog Posts by Ben Nadel

Working Code Podcast - Episode 188: Code Review Nuance

By Ben Nadel on
Tags: Podcast

From an academic standpoint, it seems that there should be one unified way in which to review code on an engineering team. A review process has a desired outcome; and, there should be a standard set of steps that help us achieve said outcome. In reality, however, code reviews are heavily nuanced. The depth of effort that we put into a review often depends on the state of the company, the individuals involved, and the type of changes being made within the Pull Request (PR). On today's show, we dig into that nuance; and, try to articulate some of the decisions that we use when we're reviewing other people's code... read more →

An "x-input" Property Binding Directive In Alpine.js

By Ben Nadel on

In my previous code kata on building a three-state toggle in Alpine.js, I used the x-effect directive to map outer scope properties onto the inner scope properties of my toggle component. Essentially, every time an outer scope property changed, the reactive aspects of the x-effect directive would turn around invoke my toggle component's reconcile() method, passing-in the updated property values. In other frameworks, this notion of input bindings and life-cycle hooks is more formally codified into the runtime. Taking inspiration from frameworks like Angular, I wanted to see if I could create an x-input directive in Alpine.js that would provide some of this behavior... read more →

Code Kata: Building A Tri-State Switch In Alpine.js

By Ben Nadel on

At work, I've been building a bulk-export feature for user prototypes. In the export experience, you can enable and disable "hotspot hinting". But, it's not exactly a binary experience. Meaning, I wanted to include a partially on state in which the hotspot hints were initial invisible; but, which would flash briefly when the user clicked on the prototype screen and failed to make contact with a transparent hotspot. To facilitate this configuration, I created a tri-state switch / toggle component:.. read more →

Using AttributeCollection To Manage Locking In ColdFusion

By Ben Nadel on
Tags: ColdFusion

The other day, when I was demonstrating how to use an ordered struct as a fixed-size cache in ColdFusion, I had to synchronize access to the cache in order to limit the number of cache keys. Whenever I make a new demo, it gives me a chance to reconsider and experiment with different approaches. And, in the aforementioned demo, I used ColdFusion's attributeCollection functionality to define my CFLock tags. This felt like a rather elegant and easily consumable approach; and I wanted to showcase it more directly... read more →

Highlighting Dynamic Parts Of A Pretty-Printed JSON Value In JavaScript

By Ben Nadel on

As part of the bulk export functionality that I'm building at work, the user needs to copy-paste a JSON value into an Amazon S3 bucket policy. This bucket policy is generated dynamically, by the app, based on the user's input. And to make the dynamic nature of the JSON value more obvious to the user, I wanted to visually highlight the values driven by the user's input. However, since the JSON payload was being generated by JSON.stringify(), it took me a while to figure out to interleave the value demarcation... read more →

Working Code Podcast - Episode 187: Viability Of The Minimum Viable Product

By Ben Nadel on
Tags: Podcast

There's no question that the bar of user experience (UX) has been raised up over the last decade of web application development. With the proliferation of technologies, frameworks, and design systems, developers can now do far more with far less. But, all software has to start somewhere (see John Gall's Law on building complex systems). Which begs the question, what level of fidelity is appropriate for your "v1"?.. read more →

Getting A Struct Key In Its Native Key-Casing In ColdFusion

By Ben Nadel on
Tags: ColdFusion

In ColdFusion, structs are case-insensitive. This is very much a feature of the language, not a bug. But, in some rare edge-cases, I want to validate that the struct key I'm using has the same key-casing that the struct itself is using. There's no native ColdFusion function for this endeavor; so, I created the user defined function, structGetKey()... read more →

OWASP Java Encoder Project Recommends Using Both URL and Attribute Encoding For HREF Attributes

By Ben Nadel on
Tags: ColdFusion

In ColdFusion, whenever I'm constructing a dynamic URL, I always run the dynamic parts through the encodeForUrl() function in order to maintain URL integrity. But, if I then use that dynamic URL to populate an anchor tag's href attribute, I end up operating in nested contexts; and, I'm always left wondering if I should have used the encodeForHtmlAttribute() function instead. For more insight, I went to the OWASP Java Encoder documentation; and, according to their "Common Mistakes" section, I should actually be using both encoding methods... read more →

Normalizing Collection Entries In ColdFusion

By Ben Nadel on
Tags: ColdFusion

In Lucee CFML, looping over collections is effortless because Lucee exposes both the key and value attributes on the CFLoop tag. Furthermore, you can even use struct instead of collection for a more intuitive read on the code. Unfortunately, Adobe ColdFusion hasn't caught up with these ergonomics niceties just yet. As such, I created a user defined function (UDF) that normalizes collections (Structs and Arrays) into an array that always exposes index, key, and value... read more →

Sorting Arrays With Priority Elements In ColdFusion

By Ben Nadel on
Tags: ColdFusion

In the companion app to my feature flags book, I have sample data for deployment environments that contains values such as "Development", "Production", and "Staging". The user can edit this sample data; but, for aesthetic reasons, I always want the collection of environments to be rendered with "Development" in the first index and "Production" in the second index, regardless of what other values the user may add to or remove from the collection. Essentially, I need a way to sort the array of environments where some of the elements are in a fixed, priority location (if they're present at all) and the rest of the elements are sorted alphabetically... read more →

Working Code Podcast - Episode 186: Work Insecurities

By Ben Nadel on
Tags: Podcast

On today's show, Carol and I shine a bright light on all of the insecurities that we continue to experience at work despite the fact that we're two high-functioning adults. It seems that no matter how much value we create for our companies—and for our customers—we're always left wondering: Am I doing enough? Am I innovating enough? Am I living up to my job title? Am I having a big enough impact?.. read more →

Creating A ColdFusion-Oriented HashCode With Loose Types (Part 2)

By Ben Nadel on
Tags: ColdFusion

The other day, I looked at creating a HashCode-inspired algorithm for ColdFusion such that you could tell if two different data structures were the same, taking into account ColdFusion's loose type system. Only, once I was done, I realized that it didn't fully serve my purposes. Ultimately, I need it for the companion app to my feature flags book; and, in my companion app, the versioning of configuration data needs to case sensitive for keys. As such, I needed to update my FusionCode.cfc ColdFusion component to allow for two configuration options:.. read more →

Working Code Podcast - Episode 185: A/B Testing Mechanics

By Ben Nadel on
Tags: Podcast

On today's show, Adam and I discuss the mechanics of A/B testing. And, how Adam might incrementally build A/B testing functionality into his existing bulk email system—a system which has been designed, over the last decade, to be performant and resilient, not necessary dynamic. The complexity of layering-on A/B testing isn't just in the coding—it's weighing the risk of the change against the value-add for the custom in the face of uncertain adoption... read more →

Extracting Illegal Tag Names From AntiSamy Error Messages In ColdFusion

By Ben Nadel on
Tags: ColdFusion

Yesterday, I observed a number of errors on my blog in which a reader was attempting to post a comment with unsupported HTML content. Only, the error was not intentional—the reader was making reference to the ColdFusion tags, <cfquery> and <cfqueryparam>; and, my AntiSamy HTML sanitization workflow was interpreting these tokens as "HTML tags". This is an easy markdown error to fix—you wrap the tags in back-ticks to denote them as code. Only, my error reporting offered up zero insight into the underlying problem. As such, I went in and updated my sanitization workflow to extract the illegal tags from the OWASP AntiSamy error messages and report them to the reader... read more →

Creating A ColdFusion-Oriented HashCode With Loose Types

By Ben Nadel on
Tags: ColdFusion

In the companion app for my feature flags book, each user's persisted configuration file has a version number. I want this version number to be incremented when the user updates their feature flags configuration; but, only if something within the configuration has actually changed. To this end, I need a way in ColdFusion to take two data structures and check to see if they are deep-equals. For that, I created the concept of a "FusionCode": a consistent, repeatable value that represents a complex data structure... read more →

Using An Ordered Struct As A Fixed-Size Cache In ColdFusion

By Ben Nadel on
Tags: ColdFusion

In ColdFusion, an ordered struct (or linked struct) is a struct in which the order of the key iteration matches the order of key insertion. Using ordered structs can be somewhat of a contentious topic because the difference between an ordered struct and a regular struct is almost invisible. But, an ordered struct can be hugely useful. For example, ordered structs are essential for MongoDB queries and can greatly simplify HMAC generation. Another use-case for ordered structs is maintaining a very simple, fixed-size cache in ColdFusion... read more →

Encapsulating Serialization Logic In ColdFusion

By Ben Nadel on
Tags: ColdFusion

Most of the time, when I need to serialize data in ColdFusion, I just reach for the built-in serializeJson() function. And, in most cases, this is a perfectly fine approach. But sometimes, I need to massage or manipulate the data as part of the serialization / deserialization workflow. If this is part of my database access layer (DAL), I might put that logic right in my data gateway; but, if I'm just dealing with flat text files, I've been encapsulating this logic inside its own abstraction... read more →

Adobe ColdFusion Parses JSON Into Non-Ordered Structs

By Ben Nadel on
Tags: ColdFusion

In ColdFusion, an ordered struct (aka linked struct) allows keys to be iterated in the same order in which they were defined. This is hugely valuable for workflows that involve MongoDB queries and Hashed Message Authentication Codes (HMAC). But, one quirky behavior that I came across today is that when Adobe ColdFusion parses JSON strings, it parses the object notation into an unordered struct. This means that you lose the "orderedness" through the serialization and deserialization workflow... read more →

Two Spread Operator Bugs In Adobe ColdFusion 2023

By Ben Nadel on
Tags: ColdFusion

I ran into two strange bugs this morning when attempting to use the Spread operator in Adobe ColdFusion (2021 and 2023). One bug prevents the CFML template from compiling; the other bug is just a completely nonsense outcome of the spread operation (at least compared to JavaScript)... read more →

Working Code Podcast - Episode 184: Code Comments For The Win

By Ben Nadel on
Tags: Podcast

On today's show, Adam and I talk about our respective strategies for leaving comments within code. Each of us inhabits a different end of the spectrum, with me erring on the side of viewing comments as an inherent value-add; and, Adam believing that the urge to add a comment is more akin to a "code smell", indicating a need to refactor the underlying code structure. We disagree on a lot in this conversation; but, it turns out, we actually agree on more than you might expect... read more →

Working Code Podcast - Episode 183: Carol's New Project

By Ben Nadel on
Tags: Podcast

On today's show, we talk to Carol about her idea for a small piece of software that will help Army families—like hers—organize their potluck social events. As web developers, the desire to start something new always comes with a mixture of emotions. On one hand, we can imagine a robust, feature-rich future with a solution that does everything we need. And, on the other hand, we can become so overwhelmed by the implementation details that taking even the first step feels near impossible. We strategize with Carol on how to take that first step; and, which questions she can answer early-on in order to unlock a more obvious path forward... read more →

Core Decision Functions Will Accept Null / Undefined Values In ColdFusion

By Ben Nadel on
Tags: ColdFusion

ColdFusion has always had a contentious relationship with null / undefined values. The ColdFusion runtime supports null and undefined values; but, if consumed incorrectly, such values lead to null reference errors. As such, it isn't always clear where you can and can't use undefined values. Today, I want to demonstrate that all of the core decision functions (such as isSimpleValue(), isArray(), and isStruct()) will accept null / undefined values; and, will do pretty much what you hoped they would do... read more →

Bug In Struct.Each() Error Handling In Adobe ColdFusion

By Ben Nadel on
Tags: ColdFusion

This is a bug I just ran into this morning while using the Struct.each() member method. If you throw a custom error inside an .each() iteration, Adobe ColdFusion—in at least 2021 and 2023—won't surface the error properly. Instead, it will surface a "wrapper" error that obfuscates the original type and message... read more →

Exploring Randomness In JavaScript

By Ben Nadel on

In my post yesterday, on building a color palette utility in Alpine.js, randomness played a big part: each swatch was generated as a composite of randomly selected Hue (0..360), Saturation (0..100), and Lightness (0..100) values. As I was putting that demo together, I came across the Web Crypto API. Normally, when generating random values, I use the the Math.random() method; but, the MDN docs mention that Crypto.getRandomValues() is more secure. As such, I ended up trying Crypto out (with a fallback to the Math module as needed). But, this left me wondering if "more secure" actually meant "more random" for my particular use-case... read more →

Color Palette Utility In Apline.js

By Ben Nadel on

A week or so ago, as I was working on my Feature Flags Book companion app, I needed to pick colors that correspond to the different variants available within a given feature flag. I'm not good at colors, so I took to Google; and, in my searches, I came across the utility site, Coolors. Coolors is very cool; but, I could only generate 5 colors for free and I needed about 7 colors for my feature flags. So, in typical "Developer fashion", I wanted to see if I could build something akin to Coolors on my own, using Alpine.js... read more →

Using Both Tab And Arrow Keys For Keyboard Navigation

By Ben Nadel on

I must admit that, historically, when thinking about keyboard-based navigation on a website, I've really only considered the Tab key for moving around and the Space and Enter keys for activation. The other day, however, I noticed something very interesting on the GitHub site: the Tab key was skipping over large swaths of buttons—buttons which, it turns out, can only be accessed using the ArrowLeft and ArrowRight keys. This kind of blew my mind!.. read more →

Generating Fake User And Company Data With ColdFusion

By Ben Nadel on
Tags: ColdFusion

As a companion piece to my Feature Flags Book, I'm creating a small playground app in which readers can explore the feature flags experience, both from a configuration and a consumption standpoint. As part of this process, I had to generate a set of fake users against which a set of configured feature flags could be evaluated. I know there are plenty of existing websites that will generate fake data for you; however, since I needed a predictable set of properties for my feature flag rules engine, I decided to generate my own fake data using ColdFusion... read more →

Working Code Podcast - Episode 181: More The Laws Of Software

By Ben Nadel on
Tags: Podcast

On today's show, we continue our discussion of the entries outlined on the website, the Laws of Software. Topics include McKinley's law on boring technologies, Doerr's law on aligning team vision, and Fitt's law on touchability... read more →

Using Range Offsets To Power Weighted Distributions In ColdFusion

By Ben Nadel on
Tags: ColdFusion

A few years ago, I looked at using arrays to power weighted distributions in ColdFusion. Using arrays is nice because they create a great visualization of the distributed values. But, creating and populating an array is a lot of overhead. As such, I wanted to revisit the idea of a weighted distribution of values; but, instead of populating an array, I'm just using calculated offsets... read more →

The 17th Annual Regular Expression Day - June 1st 2024

By Ben Nadel on
Tags: ColdFusion

Good morning my beautiful, beautiful friends and happy Regular Expression day 2024! Isn't it comforting to know that even with so much uncertainty in the world, you can always depend on the awesome power of pattern matching to help make life a little bit better—a little bit more fulfilling. And, even though there's ample opportunity to use Regular Expressions in every day life, there's always something new and exciting to try. And in celebration of this joyous day, I want to try something new (to me) and exciting in ColdFusion: using a callback operator in Adobe ColdFusion's reReplace() function... read more →


I believe in love. I believe in compassion. I believe in human rights. I believe that we can afford to give more of these gifts to the world around us because it costs us nothing to be decent and kind and understanding. And, I want you to know that when you land on this site, you are accepted for who you are, no matter how you identify, what truths you live, or whatever kind of goofy shit makes you feel alive! Rock on with your bad self!
Ben Nadel