Quiz collegato alla guida · Medio Livello

How to Write Code Documentation with AI Quiz

Check how to prompt AI for code docs, validate examples against implementation, and keep generated explanations accurate.

Domanda 1 di 8

Un assistente redige una docstring per una funzione che valida un percorso file. Cosa dovrebbe verificare prima lo sviluppatore?

Anteprima di ogni domanda8 domande

Le risposte e le spiegazioni vengono visualizzate mentre rispondi al quiz.

  1. Un assistente redige una docstring per una funzione che valida un percorso file. Cosa dovrebbe verificare prima lo sviluppatore?
    • The described inputs, return value, side effects and edge cases against the code and tests
    • Whether the prose uses the most technical vocabulary
    • Whether the comment is longer than the function
    • Whether the model sounds confident
  2. Un README dice di eseguire un comando di configurazione generato dall'IA. Qual è un passo di validazione solido?
    • Assume it works because the command is familiar
    • Remove all installation steps
    • Run it in a clean environment and confirm it matches the project scripts and configuration
    • Ask the assistant to repeat the command with more confidence
  3. Quale commento inline è più utile?
    • A paraphrase of the next line with no added context
    • A note explaining a non-obvious invariant or reason for the code
    • A claim that the function is secure without evidence
    • A list of unrelated TODOs
  4. Un esempio di API generato importa un nome di pacchetto plausibile non utilizzato nel repository. Cosa dovrebbe succedere?
    • Keep it because the package name looks conventional
    • Change the dependency file to match the example without review
    • Delete the API documentation
    • Check the import against actual dependencies and run the example
  5. Perché gli sviluppatori dovrebbero evitare di inviare segreti a un assistente di programmazione non approvato?
    • The code or context may be processed under data-handling terms that have not been approved
    • Secrets make comments harder to read
    • The assistant needs every credential to understand a function
    • A README cannot describe a credential safely
  6. A performance paragraph claims an algorithm is O(n), but no analysis or test supports it. What is the responsible edit?
    • Keep it because asymptotic notation sounds precise
    • Ask the model to invent a benchmark
    • Remove or qualify the claim until it is verified
    • Replace it with a security guarantee
  7. A new CLI flag changes behavior. When should its documentation be updated?
    • Only after users report that the README is wrong
    • With the code change and review, including a checked example
    • Never, because flags are discoverable from source
    • After deleting the tests
  8. Why might a code assistant describe an incorrect design reason even when it reads the function?
    • Source code contains every team decision automatically
    • Tests always explain product intent completely
    • Documentation never needs human input
    • The rationale or operational context may not be inferable from source code alone