Skip to content

    Unit 4 – Structure of Blockchain · 45

    Comments

    Comments are notes in source code that the compiler ignores. Solidity supports single-line and block comments, while NatSpec comments use a documented format that tools can display as developer or user-facing documentation.

    Animated diagram

    Comments are margin notes for the next person reading the recipe; they explain intent but do not change the cooking steps

    Source code → Comment → Compiler skips → Human context. Follow the flow to see how comments fits into a blockchain system.

    Make the invisible feel visible.

    Comments are notes in source code that the compiler ignores. Solidity supports single-line and block comments, while NatSpec comments use a documented format that tools can display as developer or user-facing documentation.

    Think of it like this

    Comments are margin notes for the next person reading the recipe; they explain intent but do not change the cooking steps.

    Under the hood

    How it works, step by step

    01

    Start with the idea

    Comments are notes in source code that the compiler ignores. Solidity supports single-line and block comments, while NatSpec comments use a documented format that tools can display as developer or user-facing documentation.

    02

    Follow the example

    `/// @notice Returns the current count.` documents a public function for tools and future readers.

    03

    Notice the benefit

    Clear comments explain assumptions, warnings and intended behavior during reviews and maintenance.

    04

    Check the limitation

    Comments can become outdated and cannot substitute for tests, clear code or an actual security review.

    Make it concrete

    Comments in practice

    Comments in practice

    `/// @notice Returns the current count.` documents a public function for tools and future readers.

    Key point: Comments can become outdated and cannot substitute for tests, clear code or an actual security review.

    Balanced view

    Advantages & disadvantages

    Advantages

    • Clear comments explain assumptions, warnings and intended behavior during reviews and maintenance.

    Disadvantages

    • Comments can become outdated and cannot substitute for tests, clear code or an actual security review.

    Keep these close

    Takeaways & common traps

    What to remember

    • Comments are notes in source code that the compiler ignores. Solidity supports single-line and block comments, while NatSpec comments use a documented format that tools can display as developer or user-facing documentation.
    • Clear comments explain assumptions, warnings and intended behavior during reviews and maintenance.
    • Comments can become outdated and cannot substitute for tests, clear code or an actual security review.

    Watch out for

    • Do not assume comments guarantees more than its design can prove.
    • Do not ignore the trade-off: Comments can become outdated and cannot substitute for tests, clear code or an actual security review.

    Quick check

    Questions people ask

    Why is comments useful?

    Clear comments explain assumptions, warnings and intended behavior during reviews and maintenance.

    What is an important limitation?

    Comments can become outdated and cannot substitute for tests, clear code or an actual security review.