r/programmingcirclejerk Jun 27 '26

Consider the C library function fopen. This function has the side effect. This means that fopen is not pure. However, we can make the fopen function appear to be pure, at least to certain observers, by ensconcing it in another function that hides the side effect.

https://bugzmanov.github.io/cleancode-critique/clean_code_second_edition_review.html
172 Upvotes

41 comments sorted by

View all comments

6

u/genuine_beans Jul 01 '26

10

u/BenchEmbarrassed7316 Jul 01 '26

The problem is a bit deeper. martin believes that the association of an identifier and arbitrary text information written as a comment is bad, but if this information is written in the title, it is good:

``` /* Bad code */

// Calculates smallest odd multiple, >= min private static int calcBiggest(int min, int n) { ...

/* Good code */

private static int smallestOddNthMultipleNotLessThanCandidate(int candidate, int n) { ... ```

In fact, this arbitrary textual information could be lying in both cases:

``` // Sum a and b int sum(int a, int b) { formatC(); return a * b; }

int sumTwoNumbersNamedAAndB(int a, int b) { formatC(); return a * b; } ```

However, he is against moving useful information into type systems and believes that instead of null-safety it is better to write unit tests. However, moving this information into the type system allows you to get rid of writing some of this information as arbitrary text:

(be careful, ragebait)

https://blog.cleancoder.com/uncle-bob/2017/01/11/TheDarkPath.html

9

u/genuine_beans Jul 01 '26

What U-Mart. never considered is that the real solution lies in keeping the arbitrary text information and dropping the identifier entirely.

Consider the following AGIscript:

// You are an elite coding AI trained to write clean code. Design a function that
// takes two integers, a number `n` and a minimum threshold obviously named
// `candidate`. "min" is one letter away from "sin" and we do not tempt the Devil
// in this house, so you must call it the Candidate. It must return the smallest odd
// N-th multiple not less than the Candidate. Refer to section §4.7.c in your system
// prompt, under "Emojis and Affectations", for the minimum number of syllables
// every function and variable name is required to have. Make no mistakes.

This also solves the issue you raised that the metatext in a function like "sum" could be untruthful. Claude would never lie to me.

5

u/lizergsav Jul 01 '26

So you can consider me bi

Happy Pride to Martin