DEV Community

Roman Sorin
Roman Sorin

Posted on

1

How do you like to read articles/tutorials?

When reading documentation or articles that contain code, do your prefer to:

  1. step through the file line-by-line
  2. see the full code snippet pasted with inlined comments
  3. see the full snippet, and a summary/walk-through after?

Here's an example of #2/3 taken from a recent post of mine:

import hashids from "hashids";

// Two arguments supplied: a salt and a minimum padding (length)
const postHash = new hashids("post", 8);

const post = { id: 4 };
post.id; // 4

const hashedPostId = postHash.encode(post.id);
hashedPostId; // 6akz1JVq
postHash.decode(hashedPostId); // [4]
Enter fullscreen mode Exit fullscreen mode

"Here, we're importing the hashids package and creating an instance of the module, calling it postHash. ..."

vs. doing something like:

const postHash = new hashids("post", 8);
Enter fullscreen mode Exit fullscreen mode

"First, we create an instance of the hashids module and supply a salt and padding. ..."

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay