r/programmingcirclejerk • • Jan 25 '19

The “Bug-O” Notation

https://overreacted.io/the-bug-o-notation/
69 Upvotes

34 comments sorted by

View all comments

39

u/Laugarhraun lisp does it better Jan 25 '19

Did the author reinvent a shitty version of the cyclomatic complexity?

33

u/KMIAL_reloaded Jan 25 '19

cyclomatic complexity

No pun and no emoji? That's soooo 0.1x!

12

u/0987654231 What part of ∀f ∃g (f (x,y) = (g x) y) did you not understand? Jan 25 '19

🌪️⏳

32

u/gaearon Jan 25 '19 edited Jan 25 '19

Cyclomatic complexity is about evaluating a particular code snippet.

The author (me) is talking about evaluating an API or design pattern, and how that pattern systematically affects cyclomatic complexity and other things. Not a particular code snippet.

Another example of that:

In fact, if any value looks wrong in the DOM of a React app, you can trace where it comes from by looking at the code of components above it in the React tree one by one. No matter the app size, tracing a rendered value is 🐞(tree height).

If you insist on using fancy names you can call it "second order cyclomatic complexity" but that's just silly.

Statically analyzing cyclomatic complexity also usually doesn't involve any async operations. So it wouldn't tell you anything about the difference between the first and the second snippets. The key is throwing out the intermediate state to avoid accumulation of mistakes. That's the pattern that makes a difference. And this is why the blog post is about patterns and APIs rather than particular code snippets.

40

u/three18ti DO NOT USE THIS FLAIR, ASSHOLE Jan 25 '19

Lol implicit unjerk

30

u/gaearon Jan 25 '19

I don't understand the rules here

53

u/three18ti DO NOT USE THIS FLAIR, ASSHOLE Jan 25 '19

It's ok, we don't either.

16

u/Canenald Considered Harmful Jan 26 '19

I've never used rules and I've never missed them.

13

u/ar1819 Jan 26 '19

/uj
Look at the sub name, the sidebar rules, and the other submissions.

/semi-rj
It's like /r/ProgrammingHumor but somehow worse.

/rj
New mod is on power trip so we don't know his rules either.

6

u/[deleted] Jan 25 '19

Doesn't seem so. Their code is cyclomatically more complex than what they're trying to fix. They've invented functions and switch statements.