Skip to main content
Ben Nadel at the NYC Node.js Meetup (Sep. 2018) with: Manon Metais
Ben Nadel at the NYC Node.js Meetup (Sep. 2018) with: Manon Metais ( @NYCReact )

Recent Blog Posts by Ben Nadel

ColdFusion: Comparison Method Violates Its General Contract

By Ben Nadel on
Tags: ColdFusion

This week, a single instance of an error showed up in my ColdFusion logging: "Comparison method violates its general contract!". The stacktrace pointed to something in the Java layer called TimSort; which is what ColdFusion's Array.sort() method is using under the hood. This error may be thrown if the .sort() callback / operator doesn't adhere to the set of requirements defined by the Comparable interface... read more →

Working Code Podcast - Episode 193: Bonding In The Foxhole

By Ben Nadel on
Tags: Podcast

Without a doubt, there is a special bond formed between people who've shared an intense experience. At work, we see this all the time during incident triage and remediation—there is something truly special about those Zoom calls in which everyone on the team is suddenly on the same page and is working with a singular purpose. But, do we end up glorifying these metaphorical foxholes? Can we build those lasting bonds during the good times? Or, is there something unique about a company that has gone through trial-by-fire?.. read more →

TODO: Granting Yourself Permission To Move Forward

By Ben Nadel on
Tags: Work

I just read Chris Ferdinandi's latest newsletter, Gardening and code, about the importance of solving the problems in front of you. In it, Chris touches upon an issue that we all struggle with at some point: feeling like our first solution has to be the perfect solution. It reminded me of a powerful cognitive tool that I use in my own programming: the TODO: comment... read more →

Signals And Array Mutability In Angular 18

By Ben Nadel on

Like many change detection mechanisms, Signals in Angular 18 rely on reference changes in order to trigger change detection. When consuming simple values, this is fine because simple values are passed by value, not by reference. But, when wrapping complex objects in a Signal, the mutability of objects becomes a point of consideration. It's important to understand how the change detection mechanisms in Angular work so that you don't end up falling down the immutability rabbit-hole... read more →

Exploring Lazy Evaluation Of Computed Signals In Angular 18

By Ben Nadel on

Yesterday, on Episode 192 of the Working Code podcast, I expressed a fear that the magic of reactivity might lead to unanticipated performance issues when a computed value relies on more than one dependency. But, this fear was purely theoretical. And, it turns out, unwarranted. Computed values in Angular 18 are lazily evaluated. Meaning, they are not computed until they are actually read. And, if they're never read, they're never computed. This post is a small exploration of these Signal timing mechanics in Angular 18... read more →

Building An Angular App For ColdFusion Using Docker Compose

By Ben Nadel on

In a world where containerized development exists, I feel like a failure any time I have to run a build script—such as npm install or nvm use—directly on my host computer. Containers should be obviating this type of workflow. But, the problem is, I'm not really that good at containerization. Recently, however, I had a mental breakthrough. I realized that my JavaScript builds didn't have to execute inside my ColdFusion container; instead, I could use a separate Node.js Docker container to perform the build and then output the distribution files to my ColdFusion container... read more →

Working Code Podcast - Episode 192: The Best And Worst Code

By Ben Nadel on
Tags: Podcast

On today's show we discuss some of the best code that we've seen and some of the worst code that we've seen. But, "best" and "worst" are fuzzy terms. What does it meant when we even talk about code quality? Does it relate to the maintainability of the code? Does it pertain to revenue generation for the company or how many problems were solved for the customer? Is it about being DRY (Don't Repeat Yourself) or WET (Write Everything Twice) in your intentions? How much does debuggability and logging matter? And, is the best code really just the most boring and predictable code?.. read more →

Working Code Podcast - Episode 191: Too Much Process

By Ben Nadel on
Tags: Podcast

People have a lot of trouble existing in the grey. I think we all understand that too much process exists. But, we don't know what to do about it. We have a lot of evidence that in critical arenas—such as medical care and flying planes—that checklists do save lives. But, at the same time, we all believe that spelling corrections on a website don't call for full regression testing. And yet, we do full regression testing anyway. Because, we either don't understand nuance; or, we work at companies that don't allow for human judgement within the decision making framework... read more →

Creating A Transient View Helper In Angular 18

By Ben Nadel on

One of the really nice features of Angular 18 is the ability to use a DestroyRef injectable to define your component's clean-up logic. This allows your setup and teardown logic to be collocated within the ngOnInit() life-cycle method. In order for the DestroyRef functionality to work, its own life-cycle has to be married to the host component's life-cycle. Which got me thinking about creating my own transient "View Helper" service that might make other workflows easier... read more →

Working Code Podcast - Episode 190: Career Advice To Younger Self

By Ben Nadel on
Tags: Podcast

On today's show, Carol and I reflect on our careers and come up with advice that we'd give to our younger selves. Exercises like this are always a challenge because we have to contend with counterfactuals. That is, we have to either imagine a future that could have been; or, we have to have faith that alternative paths would still have gotten us to where we are today. Neither of these are a certainty... read more →

JavaScript Application Size Shouldn't Affect Performance

By Ben Nadel on

I listen to a lot of podcasts in an effort to gain a better perspective on software development. And one sentiment that I've heard repeated a number of times across different podcasts is that as the size of a JavaScript application increases, its performance decreases. This is often touted as a reason to switch from one JavaScript framework to another—that some magical threshold has been reached. But, this sentiment makes little sense. The size of a JavaScript application should be completely disconnected from the performance of said application... read more →

Code Isn't Magical, It's Just A Series Of Commands

By Ben Nadel on
Tags: Work

For many people, it seems that working on a piece of software is like stepping into the "fog of war". There's a general sense of bewilderment about how any of it works; and a constant fear that even small changes made anywhere might suddenly cause a collapse of the entire system. But this fear is almost always misplaced. It stems from the notion that code is somehow magical. But code isn't magical, it's just a series of commands... read more →

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 →


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