News for hackers. Stuff that matters.

Ask HN: How do you personally diagram code?

UML is quite formal and involved. Drawing boxes with arrows on Lucidchart or Draw.io is easy, but the lack of detail is a liability when code gets complex.

How do you personally diagram code so there's enough detail, but you aren't constantly getting lost in the formality of the system?

( 12 comments | 11 points | on HN )
Re:Ask HN: How do you personally diagram code? by slipwalker on Sunday April 25, 2021 @05:52PM (#26937048)

  - context diagram for an overview
  - uml sequence diagram for a more detailed view of interesting parts
  - entity relatioship model for databases
Re:Ask HN: How do you personally diagram code? by jamestimmins on Sunday April 25, 2021 @06:41PM (#26937408)
Ah so you have multiple different diagrams for the same domain? I've been trying to do everything with one, which might be the problem.
Re:Ask HN: How do you personally diagram code? by joergen7 on Monday April 26, 2021 @05:42AM (#26940820)
I use Petri nets. They allow me to diagram communicating systems, making explicit how active components (like functions or services) and passive components (like storage or i/o-devices) interact.

Petri nets have formal semantics easy enough to grasp (firing rule) and provide enough optical cues to make them readable at a glance.

With a little practice, nets can be visually appealing, which helps in presentations and publications. I use Inkscape as a drawing tool.

Re:Ask HN: How do you personally diagram code? by ezekg on Tuesday April 27, 2021 @07:00PM (#26963072)
I use https://monodraw.helftone.com. A good example of how to make exceptional diagrams is brandur's blog [0].

[0]: https://brandur.org/postgres-reads

Re:Ask HN: How do you personally diagram code? by vladojsem on Monday April 26, 2021 @03:26PM (#26946857)
I use mostly Entity-Relationship for designing a database, and UML Class diagrams.

Personally I prefer typing to drag-and-drop so I use https://www.gleek.io/

Check templates and turials, or ask me if you like to know more ;-)

Re:Ask HN: How do you personally diagram code? by el_dev_hell on Sunday April 25, 2021 @09:15PM (#26938322)
I default to https://www.diagrams.net/.

But I've used Microsoft Visio in the past and it's a really nice solution (this was 3 years ago, so it might be better/worse now).

Re:Ask HN: How do you personally diagram code? by rualca on Monday April 26, 2021 @02:44AM (#26939926)
I use mostly UML.

Component diagrams and deployment diagrams for the general overview, architecture and operations-wise.

Communication diagrams for some workflows.

Sequence diagrams to show how operations are executed.

For onboarding, sometimes a class diagram or two.

Re:Ask HN: How do you personally diagram code? by joshxyz on Monday April 26, 2021 @04:41AM (#26940539)
Combination of things

- diagram for high level

- diagram for small complex things

- comment on code as necessary

- write good enough documentation that is enough to onboard people to the project structure

- write decent commit messages

Re:Ask HN: How do you personally diagram code? by type0 on Sunday April 25, 2021 @08:46PM (#26938176)
Re:Ask HN: How do you personally diagram code? by ayoubElk on Tuesday April 27, 2021 @08:34PM (#26963953)
Re:Ask HN: How do you personally diagram code? by segmondy on Sunday April 25, 2021 @07:27PM (#26937716)
paper & pen
Re:Ask HN: How do you personally diagram code? by fiftyacorn on Monday April 26, 2021 @03:48AM (#26940281)
Me too with notes scrawled all over it