Newslurp

<< Stories

The boolean trap 🪤, what devs should know about DBs 🧠, new CSS at-rule 🎁

TLDR Web Dev <dan@tldrnewsletter.com>

September 5, 11:13 am

TLDR WebDev
Using boolean flags in function parameters is a trap - enums should be used instead. Boolean flags can lead to confusion and maintenance issues 

TLDR

Together With Stytch

 TLDR Web Dev 2024-09-05

Auth done right with Stytch (Sponsor)

Stytch provides complete auth infrastructure for developers (far beyond basic widgets) and built-in fraud and risk prevention in a single, API-first platform

You can easily implement enterprise auth features like SSO, RBAC, MFA, and SCIM. And with device fingerprinting, you can secure your application from new AI threats.  

“We migrated tens of millions of users from Auth0 to Stytch in less than a month. It was far and away the easiest migration I've ever worked on.” — Archana S., Director of Engineering, Tome

✅ Trusted by Tome, Zapier, Replit, Clearbit, Cisco, Groq

Start building with Stytch

🧑‍💻

Articles & Tutorials

The Boolean Trap (5 minute read)

Using boolean flags in function parameters is a trap - enums should probably be used instead. Boolean flags can lead to confusion and maintenance issues, especially when dealing with multiple output types. While boolean flags can be appropriate in specific cases, enums are generally preferable for API and function parameters because they are more readable, maintainable, extensible, and future-proof.
CSS @property and the New Style (9 minute read)

CSS's @property is a new at-rule allowing explicit definition of custom property syntax, initial value, and inheritance. This article shows how @property enables smooth animations and transitions, demonstrated by a shiny animated button with rotating gradients, a silky smooth hover effect, and tiny shimmering dots. @property lets developers create intricate designs and complex animations, previously difficult or impossible with standard CSS.
Component testing in Storybook (11 minute read)

Component testing may be the future of UI testing. While end-to-end (E2E) tests provide the highest fidelity, they are often impractical for comprehensive UI coverage due to slow execution, difficulty in managing complex states, and setup overhead. Component tests, on the other hand, offer a balance between unit tests and E2E tests, allowing for both faster and more reliable testing. Component tests are not necessarily a replacement for E2E tests, but rather a complement.
🧠

Opinions & Advice

Explicit is better than implicit (4 minute read)

Explicit code is better than implicit code because implicit code has a higher number of WTFs per minute (basically being more frustrating and confusing). This post presents two code examples to make this point, showing how explicit code makes it easier to understand and maintain the codebase by clearly defining variables and permissions.
Things I Wished More Developers Knew About Databases (19 minute read)

Jaana Dogan, a Principal Engineer at Google, wrote a post about database-related issues commonly overlooked. It emphasizes the importance of understanding nuances like ACID compliance, isolation levels, and data consistency. It also talks about the pitfalls of auto-incrementing primary keys, optimistic locking, write skews, and clock skews.
🚀

Launches & Tools

Introducing @svg-use (16 minute read)

@svg-use is a set of tools and bundler plugins that facilitate the use of 'use href' for better SVG loading in a React context. It's more efficient than the current common practice of inlining SVG as JS code.
Midday Create v1 (GitHub Repo)

This is an open-source starter kit for building production-ready SaaS applications. It uses a curated stack of tools, including Next.js, Supabase, and TailwindCSS, organized as a monorepo with a focus on code reuse and best practices.
FetchFox (Website)

FetchFox is a Chrome extension for extracting any data from any website. It takes the raw text of a website and uses AI to extract data the user is looking for.
🎁

Miscellaneous

A Real Life Off-By-One Error (6 minute read)

There was a subtle off-by-one error during the European Climbing Championships in Villars-sur-Ollon. A hold on the right-hand side of the wall was off by one position compared to its counterpart on the left side. Despite the error going unnoticed for years, this author spotted it because he had a reference point from a previous competition and was not visually fatigued by repeated exposure to the same wall.
Intel Honesty (16 minute read)

Intel once dominated the chip industry. Despite its historic success, Intel's failure to adapt to changing market demands, particularly in mobile and AI, has led to a situation where its foundry business, Intel Foundry, is struggling to compete with industry leaders like TSMC. Intel Foundry's existence is no longer justified by market forces and the U.S. government will need to provide substantial financial support, such as purchase guarantees, for it to survive.
Exactly-Once Payments At Airbnb (8 minute read)

Airbnb manages the challenge of idempotency in payment processing by coordinating both client and server systems to avoid double charges, despite the technical impossibility of "exactly-once" delivery in distributed systems. Airbnb's approach involves splitting requests into phases and ensuring mutual exclusion to handle retries effectively.

Quick Links

The TSConfig Cheat Sheet (5 minute read)

The TSConfig Cheat Sheet is a guide to configuring TypeScript's tsconfig.json file - it includes a cheatsheet of recommended base, strictness, and project-specific options.
Code Review Anxiety Workbook (Website)

This Code Review Anxiety Workbook provides self-guided cognitive-behavioral exercises to help developers reduce their code review anxiety.
Srcbook (GitHub Repo)

Srcbook is an open-source, interactive programming environment for TypeScript that allows users to create, run, and share reproducible programs and ideas locally with a web interface.
AlphaFold3 Open-Source Implementation (GitHub Repo)

Ligo has open-sourced its implementation of AlphaFold3, letting researchers use the protein structure prediction model freely.

Love TLDR? Tell your friends and get rewards!

Share your referral link below with friends to get free TLDR swag!
Track your referrals here.

Want to advertise in TLDR? 📰

If your company is interested in reaching an audience of web developers and engineering decision makers, you may want to advertise with us.

If you have any comments or feedback, just respond to this email!

Thanks for reading,
Priyam Mohanty, Jenny Xu & Ceora Ford


If you don't want to receive future editions of TLDR Web Dev, please unsubscribe from TLDR Web Dev or manage all of your TLDR newsletter subscriptions.