Lessons for Building Resilient Codebases

Rate this content
Bookmark

The harsh reality is that software development is messy. You start with the best tools, the best architecture and the best intentions, but quality inevitably degrades over time. Frontend code is particularly fragile in time as it sits at the intersection of product, design and engineering. A while ago I started asking myself if all codebases are destined to fail and become legacy or obsolete. Then I began collecting lessons from past wins and failures and noticed how important resilience was to the success of a long term project.


Resilience is the ability of a codebase to survive through waves of chaotic development and unplanned changes. Resilience has less to do with the tools and frameworks you deploy, and more to do with the discipline of writing and maintaining clean code. Have you ever wondered how much work will be required to update the code you are writing today, 6 months from now? Let's see if we can answer that with a simple: "not too much".

This talk has been presented at JSNation 2024, check out the latest edition of this JavaScript Conference.

FAQ

Reusability can lead to benefits like deduplication and separation of concerns, but it can also cause issues like zombie code, unnecessary abstraction, and complex change propagation.

Code bases degrade over time due to various pressures such as team changes, shifting priorities, and technical debt.

Comments can become outdated as code evolves, so it's important to treat comments as part of the code and keep them updated.

Strict typing helps avoid errors and ensures that all possible states of data are explicitly handled, reducing runtime errors and flakiness in the application.

Leaving traces behind, such as comments, breaking down complex algorithms into smaller steps, and hoisting conditionals, can make code more understandable over time.

The speaker is from Cluj, Romania.

The main topic is building resilient code bases.

The speaker is a product engineer at Code Sandbox.

Collocation refers to keeping related code elements together, which helps both in writing and reading phases of coding.

The first lesson is to accept imperfection, meaning that it's essential to do a good enough job rather than striving for perfect architecture.

Alex Moldovan
Alex Moldovan
29 min
13 Jun, 2024

Comments

Sign in or register to post your comment.
Video Summary and Transcription
Code bases degrade over time, so it's important to build a protective layer and accept imperfections. Collocation and leaving traces in the code are key for better understanding. TypeScript's strict null checks and explicit typing can improve code reliability. Guidelines and naming conventions are crucial for maintaining a consistent and scalable architecture. Version control complexity is not significantly affected by having multiple components in one file.

1. Understanding Resilient Code Bases

Short description:

I'm here to talk from the role of product engineer at Code Sandbox. The problem with code bases is they degrade over time. How do you ensure that these code bases stand this stress?

Hey, everyone. Wow. I'm shocked with so many people here. I was joking, like, the biggest fear I have with a multitrack event is being in front of five people in the first row and speaking. But, yeah, thank you so much for joining this session.

Like I mentioned before, I'm coming from Romania, from a city called Cluj. I'm one of the organisers of JS Heroes. I'm not sure if anyone heard of JS Heroes or has been to JS Heroes. Nice. A few hands, cool. Yeah. Do come find me afterwards if you want to talk more about conferences and organising and community events. Happy to chat until the evening about that, if you want.

Today I'm here to talk from the role of product engineer at Code Sandbox. If you want to follow along the slides, they're already online on bit.ly. You can grab those later. There are a couple of references throughout the slides. You don't need to take pictures or anything.

I'm speaking from the experience of a product engineer and basically working at Code Sandbox for the past four years, working at previous companies in similar roles, and dealing with code bases, right? The problem with code bases is they degrade over time. This is just inevitable. What do I mean by resilient code bases? Let's talk a bit about why this is even a thing.

When you work in a product company, or you work in general at a mid-sized project, start-up, large-scale project, most of the time, the priority is going to be shifted around the features, the user needs, the business needs, not so much on the engineering side. Let's be honest, you don't have time every six months to rewrite everything or rethink the architecture or build whatever is the hottest framework nowadays.

This kept me thinking over the years. I started gathering this, you know, lessons from building these code bases. How do you ensure that these code bases stand this stress? Basically, if you take code, the code base that you have, over time, there are pressures that get applied on your code base, right? Those pressures can be team changes, people that have initially built the architecture maybe are not part of the team any more. You can have priorities shifting in the company where the code base maybe is not in a central role at this stage in time. You can have the product roadmap that has a lot of pressure again on the code base, features that you haven't even considered in the beginning when you wrote the first lines of code that now have become like the central part of your code base. The business can pivot to something else but you're still using some of the foundational work that you build at first. That gets more and more interesting with that.

2. Maintaining Resilient Code Bases

Short description:

Code degrades over time, so how do you deal with it? Build a protective layer around your code. Accept imperfection and focus on doing a good enough job. Collocation is important for both writing and reading code.

Also, time-passing, like I said, code just degrades over time, maybe technical depth accumulates, that's inevitable, so how do you deal with this?

The problem is that the more you have all these different vectors of pressure on your code, the more likely the code base will crumble or become that legacy thing that everyone hates to go back to and have to maintain something on it. The objective here is to talk about how can you make this better? How can you build this protective layer around the code that you write or what are the things that you can do to just make sure that over time, you know, code bases keep this resilience and survive these kind of external pressures?

Lesson number one is to accept imperfection, and what I mean by that is that perfect, in our case, is the enemy of good, because you have to do a good enough job. Lesson number two is related to collocation. Collocation helps both when writing the code and when reading the code.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

A Framework for Managing Technical Debt
TechLead Conference 2023TechLead Conference 2023
35 min
A Framework for Managing Technical Debt
Top Content
Today's Talk discusses the importance of managing technical debt through refactoring practices, prioritization, and planning. Successful refactoring requires establishing guidelines, maintaining an inventory, and implementing a process. Celebrating success and ensuring resilience are key to building a strong refactoring culture. Visibility, support, and transparent communication are crucial for addressing technical debt effectively. The team's responsibilities, operating style, and availability should be transparent to product managers.
Debugging JS
React Summit 2023React Summit 2023
24 min
Debugging JS
Top Content
Watch video: Debugging JS
Debugging JavaScript is a crucial skill that is often overlooked in the industry. It is important to understand the problem, reproduce the issue, and identify the root cause. Having a variety of debugging tools and techniques, such as console methods and graphical debuggers, is beneficial. Replay is a time-traveling debugger for JavaScript that allows users to record and inspect bugs. It works with Redux, plain React, and even minified code with the help of source maps.
Building a Voice-Enabled AI Assistant With Javascript
JSNation 2023JSNation 2023
21 min
Building a Voice-Enabled AI Assistant With Javascript
Top Content
This Talk discusses building a voice-activated AI assistant using web APIs and JavaScript. It covers using the Web Speech API for speech recognition and the speech synthesis API for text to speech. The speaker demonstrates how to communicate with the Open AI API and handle the response. The Talk also explores enabling speech recognition and addressing the user. The speaker concludes by mentioning the possibility of creating a product out of the project and using Tauri for native desktop-like experiences.
A Practical Guide for Migrating to Server Components
React Advanced 2023React Advanced 2023
28 min
A Practical Guide for Migrating to Server Components
Top Content
Watch video: A Practical Guide for Migrating to Server Components
React query version five is live and we'll be discussing the migration process to server components using Next.js and React Query. The process involves planning, preparing, and setting up server components, migrating pages, adding layouts, and moving components to the server. We'll also explore the benefits of server components such as reducing JavaScript shipping, enabling powerful caching, and leveraging the features of the app router. Additionally, we'll cover topics like handling authentication, rendering in server components, and the impact on server load and costs.
Power Fixing React Performance Woes
React Advanced 2023React Advanced 2023
22 min
Power Fixing React Performance Woes
Top Content
Watch video: Power Fixing React Performance Woes
This Talk discusses various strategies to improve React performance, including lazy loading iframes, analyzing and optimizing bundles, fixing barrel exports and tree shaking, removing dead code, and caching expensive computations. The speaker shares their experience in identifying and addressing performance issues in a real-world application. They also highlight the importance of regularly auditing webpack and bundle analyzers, using tools like Knip to find unused code, and contributing improvements to open source libraries.
Monolith to Micro-Frontends
React Advanced 2022React Advanced 2022
22 min
Monolith to Micro-Frontends
Top Content
Microfrontends are considered as a solution to the problems of exponential growth, code duplication, and unclear ownership in older applications. Transitioning from a monolith to microfrontends involves decoupling the system and exploring options like a modular monolith. Microfrontends enable independent deployments and runtime composition, but there is a discussion about the alternative of keeping an integrated application composed at runtime. Choosing a composition model and a router are crucial decisions in the technical plan. The Strangler pattern and the reverse Strangler pattern are used to gradually replace parts of the monolith with the new application.

Workshops on related topic

Build Modern Applications Using GraphQL and Javascript
Node Congress 2024Node Congress 2024
152 min
Build Modern Applications Using GraphQL and Javascript
Featured Workshop
Emanuel Scirlet
Miguel Henriques
2 authors
Come and learn how you can supercharge your modern and secure applications using GraphQL and Javascript. In this workshop we will build a GraphQL API and we will demonstrate the benefits of the query language for APIs and what use cases that are fit for it. Basic Javascript knowledge required.
Building a Shopify App with React & Node
React Summit Remote Edition 2021React Summit Remote Edition 2021
87 min
Building a Shopify App with React & Node
Top Content
WorkshopFree
Jennifer Gray
Hanna Chen
2 authors
Shopify merchants have a diverse set of needs, and developers have a unique opportunity to meet those needs building apps. Building an app can be tough work but Shopify has created a set of tools and resources to help you build out a seamless app experience as quickly as possible. Get hands on experience building an embedded Shopify app using the Shopify App CLI, Polaris and Shopify App Bridge.We’ll show you how to create an app that accesses information from a development store and can run in your local environment.
Build a chat room with Appwrite and React
JSNation 2022JSNation 2022
41 min
Build a chat room with Appwrite and React
WorkshopFree
Wess Cope
Wess Cope
API's/Backends are difficult and we need websockets. You will be using VS Code as your editor, Parcel.js, Chakra-ui, React, React Icons, and Appwrite. By the end of this workshop, you will have the knowledge to build a real-time app using Appwrite and zero API development. Follow along and you'll have an awesome chat app to show off!
Hard GraphQL Problems at Shopify
GraphQL Galaxy 2021GraphQL Galaxy 2021
164 min
Hard GraphQL Problems at Shopify
WorkshopFree
Rebecca Friedman
Jonathan Baker
Alex Ackerman
Théo Ben Hassen
 Greg MacWilliam
5 authors
At Shopify scale, we solve some pretty hard problems. In this workshop, five different speakers will outline some of the challenges we’ve faced, and how we’ve overcome them.

Table of contents:
1 - The infamous "N+1" problem: Jonathan Baker - Let's talk about what it is, why it is a problem, and how Shopify handles it at scale across several GraphQL APIs.
2 - Contextualizing GraphQL APIs: Alex Ackerman - How and why we decided to use directives. I’ll share what directives are, which directives are available out of the box, and how to create custom directives.
3 - Faster GraphQL queries for mobile clients: Theo Ben Hassen - As your mobile app grows, so will your GraphQL queries. In this talk, I will go over diverse strategies to make your queries faster and more effective.
4 - Building tomorrow’s product today: Greg MacWilliam - How Shopify adopts future features in today’s code.
5 - Managing large APIs effectively: Rebecca Friedman - We have thousands of developers at Shopify. Let’s take a look at how we’re ensuring the quality and consistency of our GraphQL APIs with so many contributors.
0 To Auth In An Hour For Your JavaScript App
JSNation 2023JSNation 2023
57 min
0 To Auth In An Hour For Your JavaScript App
WorkshopFree
Asaf Shen
Asaf Shen
Passwordless authentication may seem complex, but it is simple to add it to any app using the right tool.
We will enhance a full-stack JS application (Node.js backend + Vanilla JS frontend) to authenticate users with One Time Passwords (email) and OAuth, including:
- User authentication – Managing user interactions, returning session / refresh JWTs- Session management and validation – Storing the session securely for subsequent client requests, validating / refreshing sessions
At the end of the workshop, we will also touch on another approach to code authentication using frontend Descope Flows (drag-and-drop workflows), while keeping only session validation in the backend. With this, we will also show how easy it is to enable biometrics and other passwordless authentication methods.