The Messy Middle — Navigating Complexity in Large React Applications

Rate this content
Bookmark

The project started out great—the team was motivated, moving fast, and shipping features ahead of schedule. But little by little, complexity found its way in. Implementing small changes takes forever now, tech debt is piling up at an alarming rate, and everyone is losing confidence that the project will ever get done. Welcome to the messy middle. 


Taking examples from real-world projects that shipped way too late, we'll explore the symptoms and causes of complexity in large React applications, and we'll share tips and strategies for dealing with it before it takes over your codebase.

FAQ

In the context of React applications, complexity refers to anything that makes the system harder to change or harder to understand. This includes features that add to the codebase's intricacy and make modifications more challenging over time.

Complexity in large React projects tends to grow exponentially rather than linearly. As the project progresses, the increase in complexity can accelerate, making the project increasingly difficult to manage.

Component composition in React involves defining the contents of a component through child components rather than props. This approach enhances flexibility, allowing developers to easily modify elements like buttons directly without altering other parts of the component.

A deep module in React is a component that offers substantial functionality through a simple interface. It encapsulates complexity, preventing it from affecting the rest of the system, thus maintaining a clean and manageable codebase.

Reducing cognitive load involves minimizing the amount of information developers need to remember to make changes. Techniques like using clear variable names, writing insightful comments, and simplifying access rules can make the system easier to understand and modify.

To manage complexity, developers can use strategies such as component composition for flexibility, utilizing deep modules to encapsulate complexity, and reducing cognitive load to simplify understanding and modifications in the project.

Maxi Ferreira
Maxi Ferreira
10 min
15 Nov, 2023

Comments

Sign in or register to post your comment.

Video Summary and Transcription

Managing complexity in large React applications is a challenge, as it tends to grow exponentially over time. Component composition is a key technique that allows for flexibility in React applications, but too much composition can make components harder to use. Managing complexity and reducing cognitive load is crucial, and strategies such as controlling abstraction evolution and minimizing information needed for simple changes can help. Simplicity is difficult, but important in slowing down the growth of complexity.

1. Managing Complexity in Large React Applications

Short description:

Hi React Summit, my name is Maxi Ferreira and today I want to share with you some of my thoughts on managing complexity in large React applications. We often imagine complexity as growing linearly over time, but it tends to grow exponentially. I will define complexity as anything that makes the system harder to change or understand. I will share my favorite three strategies and techniques to help you manage this growing complexity in large React projects.

Hi React Summit, my name is Maxi Ferreira and today I want to share with you some of my thoughts on one of my favorite topics, which is managing complexity in large React applications. But before we start, let's picture the journey of any large project. We might imagine that it will go something like this, we're going to make steady progress over time until we finally reach the finish line, we ship to production and we go out to celebrate with our team.

In reality, though, it's much more likely that it will go something like this. Things get messy in the middle. Features now take forever to ship, tech dev accumulates very rapidly and the finish line seems to get farther away each day. The reason this happens is that we often imagine complexity as growing linearly over time. The more progress we make, the more complex the codebase grows, and we sort of expect that. But more often than not, complexity tends to grow exponentially. So when we're only halfway through the project, we can see that complexity is not slowing down. It can feel quite overwhelming.

For the purpose of this talk, we're going to define complexity as anything that makes the system harder to change or harder to understand. What I like about this definition is that we can flip it and we get exactly what we need to do to achieve simplicity, which is making things easy to change and easier to understand. So today I want to share with you my favorite three strategies and techniques to help you manage this growing complexity in large React projects, which I'm hoping will be useful, especially if you're in the messy middle of your project right now.

2. Component Composition in React

Short description:

Component composition allows for flexibility in React applications. By breaking down a large component into smaller ones, we can make changes without adding numerous props. However, too much composition can make a component harder to use.

The first one is component composition. So what do I mean by this? Here we have a location card component that takes a couple props and renders this beautiful card that we see on the right. It looks quite nice actually and it's definitely simple and easy to use. The problem with this component is that it's not very flexible so if you want to make a simple change like hiding that add to favorites button that we see there on the bottom right, then our only option is to add another prop. That's not too bad. It's just an extra prop and the component is still quite simple and easy to use. But now we get a new requirement. We also want to make a change to the label of the button in some parts of the application. Okay, I guess we can add another prop for that. And this is still okay. But we have to be careful here because now we open the door for customizing anything in this component via its interface. So guess what's gonna happen next time someone else is asked to change the color of the button in some part of the app? They're gonna add another prop. We can see how this can get out of hand pretty quickly.

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

Design Systems: Walking the Line Between Flexibility and Consistency
React Advanced Conference 2021React Advanced Conference 2021
47 min
Design Systems: Walking the Line Between Flexibility and Consistency
Top Content
Design systems aim to bring consistency to a brand's design and make the UI development productive. Component libraries with well-thought API can make this a breeze. But, sometimes an API choice can accidentally overstep and slow the team down! There's a balance there... somewhere. Let's explore some of the problems and possible creative solutions.
Build a Design System with React and Tailwind CSS
React Summit 2022React Summit 2022
27 min
Build a Design System with React and Tailwind CSS
Top Content
Tailwind CSS, with its utility-first approach is known for speeding up the development process. Combining it with the power of React, let’s see how you can build a custom design system for your project to further speed it up, make it scalable and also easy to maintain.
Walking the Line Between Flexibility and Consistency in Component Libraries
React Summit 2022React Summit 2022
27 min
Walking the Line Between Flexibility and Consistency in Component Libraries
Design systems aim to bring consistency to a brand's design and make the UI development productive. Component libraries with well thought API can make this a breeze. But, sometimes an API choice can accidentally overstep and slow the team down! There's a balance there... somewhere. Let's explore some of the problems and possible creative solutions.
Find Out If Your Design System Is Better Than Nothing
React Summit 2022React Summit 2022
20 min
Find Out If Your Design System Is Better Than Nothing
Building a design system is not enough. Your dev team has to prefer it over one-off components and third-party libraries. Otherwise, the whole effort is a waste of time. Learn how to use static code analysis to measure if your design system wins over the internal competition and data-driven ways to improve your position.
Dialog Dilemmas and Modal Mischief: A Deep Dive Into Pop-Ups
JSNation 2023JSNation 2023
10 min
Dialog Dilemmas and Modal Mischief: A Deep Dive Into Pop-Ups
Our design systems commonly feature components that show on top of other content: tooltips, date pickers, menus and teaching UI, to name just a few. Proposed updates to the web platform are about to make building these a whole lot easier. You might not even need JavaScript. In this talk, you’ll learn all about the upcoming ‘popover’ attribute, modality and the top layer.
Type-safe Styling for React Component Packages: Vanilla Extract CSS
React Advanced Conference 2023React Advanced Conference 2023
19 min
Type-safe Styling for React Component Packages: Vanilla Extract CSS
Unlock the power of type-safe styling in React component packages with Vanilla Extract CSS. Learn how to effortlessly write scalable and maintainable styles, leveraging CSS-in-Typescript. Discover the seamless integration of Vanilla Extract CSS and take your React components to the next level.

Workshops on related topic

Rapid UI Development in React: Harnessing Custom Component Libraries & Design Systems
React Advanced Conference 2022React Advanced Conference 2022
118 min
Rapid UI Development in React: Harnessing Custom Component Libraries & Design Systems
Workshop
Richard Moss
Richard Moss
In this workshop, we'll take a tour through the most effective approaches to building out scalable UI components that enhance developer productivity and happiness :-) This will involve a mix of hands-on exercises and presentations, covering the more advanced aspects of the popular styled-components library, including theming and implementing styled-system utilities via style props for rapid UI development, and culminating in how you can build up your own scalable custom component library.
We will focus on both the ideal scenario---where you work on a greenfield project---along with tactics to incrementally adopt a design system and modern approaches to styling in an existing legacy codebase with some tech debt (often the case!). By the end of the workshop, you should feel that you have an understanding of the tradeoffs between different approaches and feel confident to start implementing the options available to move towards using a design system based component library in the codebase you work on.
Prerequisites: - Familiarity with and experience working on large react codebases- A good understanding of common approaches to styling in React