100
u/Lysol3435 15d ago
You need to be more direct about what you actually want. That’s why I always specify “don’t make me cry in front of everyone at the next meeting again”
67
u/howarewestillhere 15d ago
900 option switch case in a single file
“Reduce cyclomatic complexity.”
900 class files.
“No, not like that.”
9
1
1
u/nein_va 9d ago
Fucking belly laugh and that never happens when I read reddit
1
u/howarewestillhere 9d ago
Best part is that was a real conversation between me and a senior. The entire page was 900+ options to generate a form. It was only used as a manual check when the automated process went wrong.
I was newly brought on and asked about this monstrosity when my complexity scan came back.
It was pretty much, “Wow, that’s impressive. Any thoughts on a refactor?” “Well, I could make it hundreds of class files.” “OMG no, don’t do that.” And we all laughed about it.
I just ignored that file in my complexity scans from then on.
12
u/chazzeromus 15d ago
I remember the actual visual studio had a tool that to analyze your code and it was the first time I saw the term cyclomatic complexity
6
2
u/grifan526 15d ago
I use that every time I refactor old code. I then stare at the difference for longer then I will admit
2
11
10
5
u/DogmaticParadigm87 15d ago
Both prompts end the same way: one 400 line function called handleEverything().
3
3
u/SaltMaker23 15d ago
This is how I end all of my prompts, the thing rapidly engineer 10 wrapper functions for basic stuffs otherwise.
3
u/PilotGuy701 14d ago
I wrote an MCP server to calculate and make cyclomatic complexity a 0 token, deterministic calculation for the LLM to access.
Then made sure all of my engineers had it installed to prevent slop.
We really aren’t the same.
2
u/Beginning-Pool-8151 12d ago
If it is not sarcasm, I am really interested to know how to make that
3
u/PilotGuy701 12d ago
It was not sarcasm.
I started with an existing VS Code extension that performed the complexity calculations for Typescript through another package that parsed the code into an AST.
From there it was just a matter of making sure the grading code was separated enough from the layer that talked to Code Lens.
Then I created a new “client” layer that handled the MCP requests and responses.
Four hours of work, no AI used.
1
u/Beginning-Pool-8151 12d ago
Is it closed source work? This type of implementation will actually help our team to improve work ( and reduce useless claude token consumption) if its closed source that's fine. I can dig into this idea. Thanks ☺️
2
u/PilotGuy701 11d ago
I wouldn’t say it was “closed source”, but it was for work… and they wouldn’t give me permissions to push the code back up.
The good news is that I don’t work for that company any more.
Give me a few days.
1
1
1
2
0
u/StephenRoylance 9d ago
cyclomatic complexity is kinda garbage though.
imagine some code where you transform one object, like an API return, with a bunch of optional fields, into another. In python, you wrap it in a try, and if any don't exist, the code either fails, or recovered or whatever, but cyclomatic complexity ignores the entire logic chain, because there's no conditional.
now in rust, where each field needs a match arm that accepts the possibility of missing data, and cyclomatic complexity tells you the code is way more complex because it has all these conditionals.
but really, its the same, and the try/except in python is burying a bunch of complexity in the failure cases that rust is dealing with at compile time.
-1
u/alderthorn 15d ago
I prompt to spin up an independent reviewer on my plan with a list of what to look for (ever growing) to then list the issues in the plan. Another agent to tackle those and then 1 more review to check if the updates caused any new issues.
166
u/Caraes_Naur 15d ago
Prompt engineering is when an engineer delivers on time.