Forget Bad Code, Focus on the System

Rate this content
Bookmark

Prop drilling is fine. Duplication is great. Long functions are love.

We talk a lot about bad complicated code because it’s easy to see the problem. But research shows engineers can work around self-contained bad code just fine. What really trips them up is something else entirely – architectural complexity.

Architectural complexity makes your code hard to work with, causes 3x more bugs, halves productivity, and may even cause devs to ragequit. In this talk we explore what you can do.

This talk has been presented at React Summit US 2023, check out the latest edition of this React Conference.

Watch video on a separate page

FAQ

The speaker uses the analogy of building LEGO sets, comparing older sets where pieces are sorted into different boxes, to newer sets like the Saturn V rocket, which are organized stage-by-stage, each bag containing exactly the pieces needed for that phase.

High architectural complexity can lead to a 50% drop in productivity, a three-time increase in defect density, and potentially higher staff turnover, as complex systems are harder to manage and maintain.

The speaker relates coding modularity to physical objects through the examples of modular construction in buildings and the assembly of a car engine, emphasizing the benefits of pre-defined, self-contained units that simplify overall assembly and maintenance.

The speaker appreciates the direction of server components and server actions in React, noting that while the current implementations might be 'leaky', they represent a move towards self-contained components that handle everything in one file.

The speaker describes using a dependency graph to visualize how elements of the code interact and then identifying natural modules based on tight internal connections and loose external connections.

The main focus of the talk is to emphasize that instead of obsessing over 'good' or 'bad' code, what's more critical is how you set up your entire system or architecture, particularly separating concerns by business domain rather than by technology.

The speaker suggests rethinking separation of concerns by organizing them according to business domains rather than technological layers, implying a strategic modular setup that aligns more closely with business functionality.

Swizec Teller
Swizec Teller
27 min
13 Nov, 2023

Comments

Sign in or register to post your comment.
Video Summary and Transcription
Setting up the system and separating concerns are important in software development. Modular construction and prefab units are a new trend that makes construction quicker and easier. Architectural complexity can lead to a drop in productivity and an increase in defects. Measuring architectural complexity can help identify natural modules in the code. Best practices for avoiding architectural complexity include organizing code by business domain and using prop drilling. Atomic design and organizing a monorepo are recommended approaches for managing architectural complexity.

1. Setting Up System and Separating Concerns

Short description:

You should focus on how you set up your entire system, your architecture. React's JSX and CSS in JS caused similar concerns in the past. Separating concerns by business domain is a different approach.

We hope you enjoy the rest of the talk. Thank you, and I'll see you next time. Bye-bye.

So I'm going to try to convince you today that you're focusing on the wrong thing. You're talking too much about good or bad code, and what you should actually be focused on is how you set up your entire system, your architecture.

Now, has anyone seen this slide from NextJS Conf that kind of made the rounds on Twitter? This is a server action, and what's going on is that you have a React component with SQL right there in the React component, which is a bit weird. And earlier today, David from Redwood also announced that they can now do the same thing, where you have SQL stuff mixed together with JSX stuff. Now how does this make you feel when you see this? How does it feel? Does anyone feel angry? Yes, all right. Does anyone feel upset, like kind of weird, like this is a weird, bad thing to do? All right. Now, what if I told you that's exactly how we felt about JSX 10 years ago. React launched, they came up with JSX, and all of the greybeards on the internet were like, oh my God, you're mixing HTML and JavaScript? What the hell is wrong with you? Why would you ever do that? It's separation of concerns, all of that. And then CSS, CSS in JS came along and the internet went wild again. Why are you mixing all of this together? And what if I told you that the whole point of all of this is, in fact, separation of concerns.

Now, it feels, you know, I say separation of concerns, and you might be thinking, wait, but you're mixing all of the concerns together. You have styling mixed in with database logic, you have fetching mixed in with all of the ‑‑ can I actually see my notes? All right. So you're mixing everything together. That doesn't feel like separation of concerns. But there's a different ‑‑ there's another way of thinking about the separation of concerns. What if you separated your concerns by business domain, not by the technology that you're using? The word business is doing a lot of work here. We like to ‑‑ I don't know, who here has worked with like fancy pants architects and people who have like really high sounding titles like principal engineer and stuff like that? Just give a scream. Okay. A few of you. Okay. Who here has heard them talk about domain modeling or business this, business that, that sort of thing? All right. Perfect. So this is a lot of work and ‑‑ oh, damn, I'm missing ‑‑ there was supposed to be another slide there. Okay. So the word business domain is doing a lot of work there. What the business ‑‑ what I mean by that is a good example of that is Lego. So these are two Lego sets.

2. Lego Sets and Building Process

Short description:

The Lego super car from the 90s came in a big box with 1,300 pieces. You would sort the pieces into different boxes. The Saturn 5, my second Lego set, had 1,969 pieces and came in baggies. Building the Saturn 5 rocket was easier and more fun because the pieces were separated by stage, making it easier to find and build.

They both happen to be my first big Lego sets. So on the right you have what large Lego sets used to look like in the 90s. Here's the Lego super car. It comes in a really big box. I loved it. As a kid this was like oh, my God, you get 1,300 pieces and the first thing you do, you open it up and you sort every little piece into its own little box. It takes a while. And then eventually you can start building your Lego and you have ‑‑ you can find all the pieces. If you need a gear, it's in the gear box. If you need a wheel, it's in the wheel box.

Now, later, when I realized that, hey, I'm now an adult, I can just buy Lego whenever I want. I know, like crazy idea. I bought the Saturn 5, which was my second Lego set. That one has 1,969 pieces, which I think is carefully calibrated to coincide with when Apollo 1 landed on the moon and all of that, because it went up in the Saturn 5. That one didn't come with a box that you sort Legos in. It came in a bunch of baggies. You build the Saturn 5 rocket by going stage by stage. For those of you who don't know, rockets are multi-stage. It launches. The first stage burns up its fuel. It drops the first stage, and the rest of the rocket keeps going. That's how you build the Saturn 5. In each baggie, you get exactly the pieces for one stage of the rocket. You build it up from the ground, and all the pieces are mixed in. You have pieces that are from the outside panelling. You have pieces that go for the inside structure and all of that. It's all jumbled together. What's really cool is that it's much easier and much more fun to build than the supercar was because you never have to search through more than like 200 or 300 pieces, which is much easier to do. You can spread them out on a table and you're like, oh yeah, that one, that one, that one, and you just build it and you're enjoying the building process rather than spending a lot of time searching for the right LEGO. Now I know some people say that's the fun part.

QnA

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

AI and Web Development: Hype or Reality
JSNation 2023JSNation 2023
24 min
AI and Web Development: Hype or Reality
Top Content
This talk explores the use of AI in web development, including tools like GitHub Copilot and Fig for CLI commands. AI can generate boilerplate code, provide context-aware solutions, and generate dummy data. It can also assist with CSS selectors and regexes, and be integrated into applications. AI is used to enhance the podcast experience by transcribing episodes and providing JSON data. The talk also discusses formatting AI output, crafting requests, and analyzing embeddings for similarity.
Confessions from an Impostor
JSNation 2022JSNation 2022
46 min
Confessions from an Impostor
Top Content
The Talk discusses imposter syndrome and reframes it as being a professional imposter. It emphasizes the importance of sharing and starting, embracing imposterism, and building inclusively for the web. The speaker shares personal experiences of being an imposter in various technical disciplines and highlights the significance of accessibility. The Talk concludes with the idea of building a collective RPG game to remove excuses for not making things accessible.
Improving Developer Happiness with AI
React Summit 2023React Summit 2023
29 min
Improving Developer Happiness with AI
Watch video: Improving Developer Happiness with AI
GitHub Copilot is an auto-completion tool that provides suggestions based on context. Research has shown that developers using Copilot feel less frustrated, spend less time searching externally, and experience less mental effort on repetitive tasks. Copilot can generate code for various tasks, including adding modals, testing, and refactoring. It is a useful tool for improving productivity and saving time, especially for junior developers and those working in unfamiliar domains. Security concerns have been addressed with optional data sharing and different versions for individuals and businesses.
VS Code Can Do That!
JSNation Live 2021JSNation Live 2021
28 min
VS Code Can Do That!
The Talk covers various tips and features of using VS Code, including the command palette, Zen mode, external terminals, and debugging. It also highlights advanced editing and refactoring features, Git integration, and the use of dev containers. The speaker demonstrates how to set up a dev container for a Python app, run code in a container, and create and configure dev containers. The benefits of using dev containers are also discussed, such as eliminating manual configuration, handling dependencies, and facilitating team-based development.
A Quick and Complete Guide to Measuring Your Tech Debt and Using the Results
TechLead Conference 2023TechLead Conference 2023
27 min
A Quick and Complete Guide to Measuring Your Tech Debt and Using the Results
Watch video: A Quick and Complete Guide to Measuring Your Tech Debt and Using the Results
This Talk discusses the measurement and interpretation of tech lead, focusing on tech debt. Tech debt is a tool to temporarily speed up development but can have negative consequences if not managed properly. Various tech debt metrics, including heuristic metrics and second-tier metrics, can help identify and manage tech debt. Tech debt interest is crucial for measuring the impact of tech debt and allows for prioritization. It is important to collect and analyze tech debt metrics to ensure software and team health.
Webdevelopment Tailored for 2024
React Summit 2024React Summit 2024
7 min
Webdevelopment Tailored for 2024
Today's Talk covers native features in browsers, including upcoming ones and the Interop Project. Native features offer speed, compatibility, and improved debugging. Notable examples include dynamic viewport units, flexbox/grid gap, container queries, and motion path. The Interop Project ensures consistent web platform features across different browsers. Upcoming features like native CSS nesting and entry/exit animations are on the horizon.