Skip to content

What's the best way to clearly show differences between two blocks of code? #187

@carols10cents

Description

@carols10cents

From #180 (comment).

Problem

If we start with one pretty sizeable chunk of code, and then modify it to build on it, we need to make it clear what parts have been added, modified, or deleted when going from the first block to the second block. This will help readers to follow along with less of a chance of getting a weird error because they missed an edit.

Possible solutions

  • Suggested by nostarch: bold the code that has changed
    • Problem: additions and edits look the same, deletions are hard to see
    • Suggested solution to the deletion problem by @phrohdoh - use strike-through for deletion
    • Does bold and strike-through make the code look too different from how code is expected to look? Would intra-line edits lookwork ok?
  • Hide the lines that haven't changed
    • Hard to see where the changes are in context, again hard to see deletions
  • Use git diff syntax, with line numbers ideally
    • Is this readable and familiar enough to be understandable?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions