Live data from Hacker News

Don't write clean code, write CRISP code

bitfieldconsulting.com

151–160 of 170 posts

Re: Don't write clean code, write CRISP code

#151

What CRISP is supposed to mean: Correct Readable Idiomatic Simple Performant Notice that all this is just well-wishing and suitably vague, so that you feel the need to buy a book & hire a consultant to explain it to you. The trick is there's nothing to explain.

It makes sense if you read the article.

Correct: the primary objective. Code that does what it's supposed to, bug free.

Readable: strive to write code that will be understandable by others (and your future self). Review what you wrote and be your own critic when it comes to clarity.

Idiomatic: Write code the way people in your community expect to read. Don't surprise them with your own quirky and clever conventions, when there are well established and perfectly acceptable ones already.

Simple: Your code should do what it says it does directly, with no funky side-effects. Repetition is not always a sin, don't DRY things up just for the sake of it. Don't do too many things. Be parsimonious.

Performant: be aware of RAM (a bit of a letdown).

The last point was disappointing, as I was expecting something about coding to data structures when it matters. Instead the author went on about being aware of memory.

Re: Don't write clean code, write CRISP code

#152

This essay is great. Regarding simplicity, a couple of amusing observations: "I apologize for such a long letter - I didn't have time to write a short one." - Mark Twain (a variation of the French original by Blaise Pascal) Similarly for writing software: First, get it right. Then, as with writing in general, rewrite ruthlessly until it is clean, beautiful, and simple. Simplicity might be "defined" the way Justice St…

Reminds me of the quote by Kent Beck (allegedly): "Make it work. Make it right. Make it fast".

First throw something together that works, then refactor it to make it "right" (clean, readable etc). Finally optimize it if it's necessary.

Like the author of this article describes it "Write more bad code. [..] Get answers. Learn as much as you can about the problem you’re trying to solve [..] it’s much faster in the long term to write bad code then make it good, than to try to write good code in the first place" https://medium.com/swlh/coding-faster-make-it-work-then-make...

Re: Don't write clean code, write CRISP code

#153

DRY is probably my least favourite programming meme. There are far too many overzealous juniors who learned it and have a bee in their bonnet about creating absurd abstractions around any two lines of code (or config) that have vague or imagined similarities, locking in all sorts of annoying indirection.

It's definitely something that people overdo. But sometimes, especially with things like terraform, you have to struggle against the DSL to avoid having thousands of lines of repetitive code to do what could done in 100. I'll go quite far to avoid the situation I saw at at previous company, where they had 36k lines of trash to run a few data centers. Deploying a new data center was next to impossible.

Re: Don't write clean code, write CRISP code

#154

DRY is probably my least favourite programming meme. There are far too many overzealous juniors who learned it and have a bee in their bonnet about creating absurd abstractions around any two lines of code (or config) that have vague or imagined similarities, locking in all sorts of annoying indirection.

My take is the opposite. DRY can be overused, but it is much easier to “undry”, than it is to consolidate duplicate code which should have been dry from the beginning. Sections of duplicate code tend to drift apart over time, making it more difficult to consolidate down the road.

Re: Don't write clean code, write CRISP code

#155
A summary.

Correctness: the primary objective. Code that does what it's supposed to, bug free.

Readable: strive to write code that will be understandable by others (and your future self). Review what you wrote for clarity and be your own critic.

Idiomatic: Write code the way people in your community expect to read. Don't surprise them with your own quirky and clever conventions, when there are well established and perfectly acceptable ones already.

Simple: Your code should do what it says it does directly, with no funky side-effects. Repetition is not always a sin, don't DRY things up just for the sake of it. Don't do too many things. Be parsimonious.

Performant: be aware of RAM (a bit of a letdown, was expecting "code to data structures" advice).

---

Author concludes with a few interesting take-away points. Some highlights (paraphrasing):

- don't trust foolproof software engineering methodologies sold using a neat backronym.

- words like "clean", "simple", and "readable" are as vague as "freedom", "justice", or "equality".

- neat slogan like "don't repeat yourself" or "clean code" are moot.

- correctness above all else.

- tests only prove that the code can pass the test.

- No info is better than bad info. No tests is better than bad tests.

- all software has two types of bugs: those you've found and those you have yet to find.

- we all want readable code, but we have different definitions of "readability".

...

Re: Don't write clean code, write CRISP code

#156

Very often it's the design pattern people that make code unreadable.

So true. Sometimes, you read some source and you think "surely, there was a simpler way to implement whatever this is". Then you notice that the class name ends with "Visitor". Mystery solved. Now go make yourself a coffee, a pattern has been deployed.

Re: Don't write clean code, write CRISP code

#157
post #17

Since we’re adding new backronyms every day, I propose SIMPLE. S - Spaghetti: write tapestry of code like a chef. I - Interlinked: if the project has modules, they should all depend on each other (we are strongest when we can depend on one another). M - Micromanaged: if the product owner doesn’t expect reports in the daily stand-up, do they even care? P - Perplex: diversity for the codebase. L - Lazy: Bill Gates once…

> Since we’re adding new backronyms every day, I propose SIMPLE.

> S - Spaghetti: write tapestry of code like a chef.

> I - Interlinked: if the project has modules, they should all depend on each other (we are strongest when we can depend on one another).

> M - Micromanaged: if the product owner doesn’t expect reports in the daily stand-up, do they even care?

> P - Perplex: diversity for the codebase.

> L - Lazy: Bill Gates once said “I choose a lazy person to do a hard job, because a lazy person will find an easy way to do it”, for example, without testing, collaborating with team members, or ensuring the feature works with anything else in the codebase.

> E - Opinionated: because I believe E should stand for opinionated and everyone else will have to work around this with adapters. But E should mean Opinionated because Uncle Bab said so.

Re: Don't write clean code, write CRISP code

#160

Earlier quoted context omitted.

My take is that all this WET/DRY wisdom makes people think about abstractions in the wrong way -- it makes us debate them in term of when, rather than what and why. In my mind, the point of abstraction is to transform models such that we can build solutions in a way that is a better fit for the problems at hand. Reducing LOC and repetition is explicitly not the goal, sometimes a good abstraction may actually result i…

I agree with rather having good or correct abstractions than saving LOC. However, a bad abstraction can give readers/devs the wrong idea about what is behind it, how it works or how it can be used and when to rely on it. Unreliable abstractions are terrible. Leaky abstractions are also terrible. Both introduce a lot of mental load overhead.

Some people choose “no abstraction” over “poor abstraction,” which I don’t understand. Working without any abstraction is the same as working with an infinitely leaky abstraction.
Post reply on HN