Загрузка видео...

Не удалось загрузить видео

На главную

Morning Bathrobe Rant: CRAP.

26,411 просмотров • 6 месяцев назад •via X (Twitter)

Комментарии: 47

Фото профиля Bored Devops ☠️🛠⚙️
Bored Devops ☠️🛠⚙️6 месяцев назад

I think picking an acronym and then figuring out what it means is SHIT. And by SHIT, I mean Shoe-Horning In Terminology. 😉

Фото профиля Bored Devops ☠️🛠⚙️
Bored Devops ☠️🛠⚙️6 месяцев назад

👏

Фото профиля Kenneth Eversole
Kenneth Eversole6 месяцев назад

This man is living the dream. Talking shit and living some where with an incredible view

Фото профиля RC
RC6 месяцев назад

How do I tell it to cut the CRAP if I don’t know the acronym definition? I bet it will figure it out. I’ll try it on my project proposals

Фото профиля Uncle Bob Martin
Uncle Bob Martin6 месяцев назад

It will figure out the acronym. Also, have it write a crap tool specific to your application. Don’t run somebody else’s crap tool. You can use one of mine as a template if you like, just tell the AI to look at it and then write one for your application.

Фото профиля Zach Frey
Zach Frey6 месяцев назад

@RCallsign Still trying to wrap my brain around this recommendation. Why is it helpful to have CRAP tooling that’s application-specific? Language-specific is obvious, and I can see language + framework specific, but what do I get out of the next step to application-specific?

Фото профиля Uncle Bob Martin
Uncle Bob Martin6 месяцев назад

Crap depends upon two separate metrics. Coverage and Cyclomatic Complexity. CC is language dependent. Coverage is architecture dependent. In a simple monolith coverage is pretty simple to measure. But if you a system composed of N threads it gets trickier. N processes makes it even trickier. N services makes is even trickier than that.

Фото профиля Zach Frey
Zach Frey6 месяцев назад

@RCallsign Aha! That explains the disconnect. I’m thinking of coverage only in terms of source line coverage or branch coverage. Thanks! Is there somewhere you already explain how you work out your coverage analysis?

Фото профиля Uncle Bob Martin
Uncle Bob Martin6 месяцев назад

I generally use the standard coverage tools. I have also asked the agents to build custom coverage tools. Here's one of the secrets to using AIs. YOU don't have to figure out the details of how to do it. You just need to tell the AI what you want. You have to be smart about it, and have the insight to know when they are "lying" to you. But for the most part you can just say things like: "I've got three processes that communicate with each other, and I want to measure the overall test coverage that follows the thread of execution through each."

Фото профиля Richard Askew
Richard Askew6 месяцев назад

I have used cyclomatic complexity and test coverage with Claude Code . Claude Code’s comments on the tools: “Cyclomatic complexity — measures the number of independent paths through code. High complexity = harder to test, harder to reason about. Tools: radon (Python), lizard (multi-language). Test coverage — measures what percentage of code paths are exercised by tests. Tools: (Python), pytest-cov.”

Фото профиля SweatSpots 🏃🏼‍♂️
SweatSpots 🏃🏼‍♂️6 месяцев назад

CRAP index! Will give it a try. Maybe Claude Code will produce less crappy code. My 2 cents to force AI to refactor code. Set a max lines per file. If the file has too much lines, then AI has to refactor to pass the quality gate.

Фото профиля Uncle Bob Martin
Uncle Bob Martin6 месяцев назад

@SquidCorp_ink Instead of setting a max lines per file limit, I tell the agent to split any file that has more than N mutation points. The mutation tester I had the agent build has a scan mode that reports the number of mutation points, without actually mutating them.

Фото профиля SweatSpots 🏃🏼‍♂️
SweatSpots 🏃🏼‍♂️6 месяцев назад

Interesting approach. I was also considering a token approach. What if the limit was tokens? The agent already thinks in tokens, so a token budget per file is more natural than a line or mutation points count. Curious to have your opinion on that.

Фото профиля Uncle Bob Martin
Uncle Bob Martin6 месяцев назад

@SquidCorp_ink I've tried to ask the agents to measure their tokens. They seem unable to comply.

Фото профиля SweatSpots 🏃🏼‍♂️
SweatSpots 🏃🏼‍♂️6 месяцев назад

Yeah agents are bad with mathematics, but it could be done afterward, in a quality gate. /!\ this file has to many token! refactor.

Фото профиля Omer Gronich
Omer Gronich6 месяцев назад

That last part was crucial. Don’t set the agent on the warpath to reduce CRAP without setting up acceptance tests first! Removing a bunch of code is much easier for an AI to do to get better CRAP scores than actually refactoring 🙈

Фото профиля Uncle Bob Martin
Uncle Bob Martin6 месяцев назад

Yes, it's hard. Clickbait culture drives politicians to hyperbole. But some are worse than others. Some lie in their hyperbolic pejoratives more than others. Choose wisely -- not emotionally.

Фото профиля Omer Gronich
Omer Gronich6 месяцев назад

🤔

Фото профиля Marcel Albrecht
Marcel Albrecht6 месяцев назад

@unclebobmartin There was another political post he made, so maybe he replied to the wrong comment lol

Фото профиля Uncle Bob Martin
Uncle Bob Martin6 месяцев назад

@OmerGronich Yeah, I hit the button on the wrong post. Sorry about that.

Фото профиля Tony Simons
Tony Simons6 месяцев назад

I told my Hermes agent to cut the crap. It deleted my developer website and said “Done. Want me to hit the review site next?”

Фото профиля Jim Humelsine
Jim Humelsine6 месяцев назад

"CRAP" comes from "Change Risk Anti-Patterns" If the term came first, then it's a backronym. Here's a reference:

Фото профиля Mordechai Hammer
Mordechai Hammer6 месяцев назад

Definitely learned a thing or two from this one (so thank you bob!), but I’m curious… your tone (+ criticism of backronyms) sounds like maybe you think CRAP isn’t all that it’s cracked up to be. Or maybe cynicism about AI in general? Would love to know how ya really feel.

Фото профиля David Lin-Clark
David Lin-Clark6 месяцев назад

@unclebobmartin Curious offhand what you might say about one of my applications which for example seems to be pure and utter CRAP, but works fine for its intended case, any reason to be non-plussed about it or can I remain generally plussed for that specific application?

Фото профиля Uncle Bob Martin
Uncle Bob Martin6 месяцев назад

The AIs are much more tolerant of bad code than we are. But that doesn't mean their tolerance is infinite. I have seen AIs "lose it" over bad code. They thrash around, making this change and that change, unable to get a feature working because every change they make breaks something else. Having said that, my thresholds for crap are generally higher for an AI than for humans (myself). For code that I must maintain, I drive crap to 4 or below. I've had pretty good luck with agents even when the crap is only driven below 6. I am loathe to try 8, just on general principles.

Фото профиля Pascal
Pascal6 месяцев назад

How does one control the quality of the tests?

Фото профиля Uncle Bob Martin
Uncle Bob Martin6 месяцев назад

Crap, Mutation testing, and Scrap. The latter is a tool I recently built that measures the quality of the tests. It looks for setup duplication, long test chains, etc. It is very specific to clojure and speclj. But if you point an agent at it, you can get the agent to make a tool for your language and environment. Expect to fiddle with it.

Фото профиля Pascal
Pascal6 месяцев назад

Awesome. Thanks

Фото профиля Andrej Szontagh
Andrej Szontagh6 месяцев назад

But .. how the AI "measure" the CRAP? You can tell the test coverage but you let the AI to glance over the code and eyeball the complexity? Is there a tool for that?

Фото профиля Uncle Bob Martin
Uncle Bob Martin6 месяцев назад

There are several tools, but I suggest that you ask the AI to build one for you. You can point it to one of the tools you find on the web ( or and then tell it to build you a tool like that, but specific to your application and environment.

Фото профиля Andrej Szontagh
Andrej Szontagh6 месяцев назад

Oh, thank you. What a coincidence, I am working on the Java project.

Фото профиля Dwayne
Dwayne6 месяцев назад

Keep going uncle Bob, I'm almost there.

Фото профиля Mvrck
Mvrck6 месяцев назад

Are there any cases where you would want to contract many functions back into one function? If yes, what metrics would govern those decisions?

Фото профиля Uncle Bob Martin
Uncle Bob Martin6 месяцев назад

There have been times, while I was writing the code, that I have done that. It has to do with coupling and entanglement. Sometimes the union of two highly coupled functions is the simpler option. I have, from time to time, asked the agents to analyze the coupling between modules and unify those functions that could benefit. This works. The agents are pretty good at describing why they choose candidates and how they are going to unify them. Still, I'd rather this was better automated. Measuring this is a bit tricky. It has to do with the number of function arguments and tramp data that passes through a function into another. I'll be working on this in the weeks to come. In the meantime, since those situations are relatively rare, splitting remains the best option along with occasional agent driven unification.

Фото профиля Dimi
Dimi6 месяцев назад

The tests that it writes - are just … mindless, sometimes i feel like i’m wasting my tokens

Фото профиля Uncle Bob Martin
Uncle Bob Martin6 месяцев назад

That's why we also use mutation testing. Mutation testing drives the tests to be so thorough that any change to the source code will cause a test to fail. Then, even if in your view the tests are mindless, they are thorough, and when the agents break something you'll know about it immediately. And, of course, the meaningful tests are the acceptance tests that you keep control of.

Фото профиля Dimi
Dimi6 месяцев назад

Thanks, uncle Bob 🙏 - I will invest more into acceptance testing and extend my workflow with an Acceptance Test Agent

Фото профиля 0byte
0byte6 месяцев назад

curious to hear the rant about LLMs benchmarks

Фото профиля Andre Burnt
Andre Burnt6 месяцев назад

Thank you for your guidance, Uncle Bob! TDD is key when working with AI. Has anyone had success applying TDD to UI/UX tasks with AI, when product and design teams are usually in the loop?

Фото профиля Martin Wickman
Martin Wickman6 месяцев назад

What about cognitive complexity? Seems much nicer and models digest that better imo

Фото профиля Uncle Bob Martin
Uncle Bob Martin6 месяцев назад

I think cyclomatic complexity and cognitive complexity are strongly related. Moreover the cognition of an AI is much greater than that of a human. The AI can keep more than 7+-2 simultaneous things in its "mind". So what is cognitively complex for us, is relatively easier to understand for them. Thus i've had good results with limiting CRAP to 6 -- even though for a human I'd set it to 4.

Фото профиля Jesse Jr Lim (林振燊)
Jesse Jr Lim (林振燊)6 месяцев назад

Ehhh I'd get it to do a crap audit first get it to pick out problem areas then maybe slowly lower it bit by bit .. I have trust issues 🤣

Фото профиля Andrew Rulnick
Andrew Rulnick6 месяцев назад

Exactly. PHP WASM

Фото профиля Lynn Cole
Lynn Cole6 месяцев назад

So Bob, I get where you're coming from here, but cyclomatic complexity is necessary. At least some. The whole reason we care about the issue in the first place is because too much means your code is impossible to reason about. And, as a developer you care about that because being able to reason about your code is important. But in real life, especially when people follow the Uncle Bob school of engineering (and I've seen this in production), you actually end up with the opposite problem. Having functions that are so spread out with little or no cyclomatic complexity (assuming a conventional logic tree style app in a conventional programming language), what you end up with is a bloated function space, and code that's so sparse... you still can't reason about it. And then you end up in this place, where right back where you started. With an app that can't be reasoned about. What's the solution there?

Фото профиля Swapnil Khambayat
Swapnil Khambayat6 месяцев назад

It’s absolutely CRAP! isn’t it?

Фото профиля timtikitaka
timtikitaka6 месяцев назад

Are you saying that I should throw my clean code book in the trash? I don’t even need to read code anymore, let alone write it?

Фото профиля Uncle Bob Martin
Uncle Bob Martin6 месяцев назад

No. You need to understand what makes code clean so you can drive the agents to make _their_ code clean. And you need to do that in a way that does not force you to become the bottleneck in the system by reading all the code. So, should you know the principles of clean code? Yes. Otherwise you could not drive the agents to write it.

Похожие видео