Skip to content
DevMeme
3862 of 7435
Apple Comments With Architecture Diagrams
Documentation Post #4205, on Feb 12, 2022 in TG

Apple Comments With Architecture Diagrams

Why is this Documentation meme funny?

Level 1: A Map Inside The Code

This is like opening a recipe and finding not only the steps, but also a little map showing where every ingredient comes from and who carries it to the kitchen. The funny part is that many programmers write tiny notes, while this code has a whole instruction poster inside it.

Level 2: Why The Comment Helps

Swift is Apple's programming language used across many Apple platforms and open-source tools. DocC is Apple's documentation system, and the screenshot appears to show code related to resolving links between documentation pages. Link resolution means taking a reference and figuring out what page, symbol, or external destination it should point to.

The large ASCII diagram is useful because link resolution is not a single local function call. The visible boxes show a documentation context registering a bundle, resolving links, using an out-of-process resolver, requesting information from a server, and writing linkable entities. That is a lot of behavior to infer from code alone.

For a junior developer, this is the difference between a weak comment and a strong one. A weak comment says // set title right above title = value. A strong comment explains the system boundary, the reason for a design, or the contract another part of the system depends on. This screenshot is funny because it is dramatically more thorough than the comments most teams actually maintain.

Level 3: Comments With Load-Bearing Diagrams

The screenshot starts like normal Swift source:

import Foundation
import Markdown
import SymbolKit

Then it swerves into a full architecture note. The comment begins with Link resolution works in two parts: and proceeds to diagram DocC, a backend endpoint, an out-of-process resolver, server requests, other sources, and conversion steps like writing linkable entities. Below that, the actual code defines:

public struct LinkDestinationSummary: Codable, Equatable

The joke is scale. Most developers feel virtuous after adding // handle edge case. This screenshot shows a comment block that behaves like a miniature design document, complete with an ASCII sequence/flow diagram. The post text compares ordinary commenting habits against Apple's open-source style, and the image backs it up: this is not a comment explaining what one line does; it explains why several moving parts exist and how they communicate.

That matters because good documentation is not just more words. The best comments preserve context that the code cannot express locally: why link resolution is split, what data crosses process boundaries, what external references require, and what future maintainers must not accidentally break. The code can show a struct with properties like kind, language, path, referenceURL, title, and abstract; it cannot, by itself, show the system choreography that makes those fields necessary.

The funny sting is that this level of commenting makes everyone else's "self-documenting code" speech sound a little underfunded. Sometimes code is clear, and sometimes the architecture needs a map because the architecture is, inconveniently, architecture.

Description

A dark-theme code editor shows Swift source with line numbers, beginning with `import Foundation`, `import Markdown`, and `import SymbolKit`. A long comment explains "Link resolution works in two parts" for DocC, describing documentation bundles, external references, resolvers, and summaries of linkable elements. The middle of the file contains a large ASCII flow diagram labeled with pieces such as "DocC," "Backend endpoint," "DocumentationContext Register bundle," "DocumentationContext Resolve links," "Out-of-process resolver," "Request information from a server," "Other sources," and "ConvertAction write linkable entities." Below the diagram, the code defines `public struct LinkDestinationSummary: Codable, Equatable` with documented properties including `kind`, `language`, `path`, `referenceURL`, `title`, `abstract`, and `availableLanguages`, turning a comment block into a miniature architecture document.

Comments

14
Anonymous ★ Top Pick Apple looked at `// TODO: explain this later` and shipped a small RFC inside the comment block instead.
  1. Anonymous ★ Top Pick

    Apple looked at `// TODO: explain this later` and shipped a small RFC inside the comment block instead.

  2. @saidov 4y

    That’s impressive

  3. dev_meme 4y

    Asciiflow.com For the flowchart (Or monodraw, as suggested below)

    1. @feskow 4y

      Thanks, that's better than vim boxes o:

  4. @dsmagikswsa 4y

    Tool: https://monodraw.helftone.com

    1. @jor_ban 4y

      God bless you

  5. @saniel42 4y

    Unity Input System moment

  6. @TERASKULL 4y

    Apple has open source stuff? wow

    1. @QutePoet 4y

      Print system for Linux CUPS for example. It's the only one that works normally.

  7. dev_meme 4y

    Fuck programming, i'm going straight to McDonald's

    1. @dsmagikswsa 4y

      They hire programmers though.

      1. dev_meme 4y

        Good news

        1. @dsmagikswsa 4y

          https://www.reddit.com/r/ProgrammerHumor/comments/sme74n/mcds_playing_hardball_do_you_think_theyd_at_least/ Not sure, they pay you as their standard as well.

          1. dev_meme 4y

            Lol

Use J and K for navigation