DEV Community

Discussion on: Clean code... Why bother?

Collapse
 
amitnovick profile image
Amit Novick • Edited

I like the idea behind this post.

That said, in general, code sucks as a medium for informal reasoning (the kind of reasoning where you try to understand something's behaviour by observing it). On top of that, our tools (text editors, CLI programs, version control systems) are heavily code oriented which makes changing the status quo pretty hard.

The best we can achieve is either:

  1. Write code that is supposedly easier to understand
  2. Use code only as a low-level source for generating other artifacts which we can understand more easily: e.g. state machines or statecharts (images not my own).

These days when developing JavaScript I like to use XState for generating (✨ interactive!) graphs from my code. The benefit of such graphs is being able to understand how stuff work before adding features / making changes, and thereby avoiding common pitfalls that become obvious as soon as you look at the visualized graph, but are easy to miss with just code alone.