React Code Optimization Day 45: Simplifying Complexity

#100DaysOfCode Day 45/100 Tonight I promoted some information for the weekend and emailed myself a bunch of resources. Big snow coming to New England :) The resources focused on suggested folder structures in React, some alternatives, and style guides for JavaScript from both Google and AirBnB. I also looked up some more suggestions for Cursor. So far, I’m finding that less complex functions in shorter files seem to net better results. I also risked the “Allow Everything” command in Agent mode and saw its capabilities and risks. It broke something :) One cool thing was running the complexity report on the scripts comprising the complexity report. Some functions were ridiculous, 50-350+ complexity. A few context windows got everything below 10 decision points per function. I’m almost done covering all decision points for my codebase. I want to use my test descriptions and function names to compile a larger list so that I can cover practically all iterations of decision point creation in JavaScript/React/TypeScript. That way I can write a test file covering ideally all possible use cases just to try my best to eliminate decision points that aren’t broken down into the complexity table. I also want to rebuild the breakdown table so that every decision point type is within its own header: - if, else if, ternary, catch, case, ?., ??, &&, ||, default params, loops of each kind, base, and maybe something else I’m forgetting I’ll then explore with restyling or adding in some filtering/sorting for the table in case users want to filter out less complex items. I have some more to do, but I really look forward to exhausting complexity. It’s a fun visual report that leverages ESLint and JavaScript syntax. Maybe I’ll look at cognitive too for good measure idk. Really trying to tackle architecture to make the right lintings an cursor rules. Exploring attributes like file size, function size, max statements, and how they can be enforced by ESLints is going to inform me on how I can best look at for an just understand what’s going on. Really looking forward to better understanding feature va share separation or concerns too, things like “unidirectional codebase architecture” and whatnot. Lots more to go. They can get back to just having ideas and running with them. No use going past the point of no return.

To view or add a comment, sign in

Explore content categories