Quiz collegato alla guida · Medio Livello

How to Prompt AI for Better Code Quiz

Tests coding prompt specificity, examples, relevant context, task decomposition, test design, and review of generated changes.

Percorsi guida correlatiPrompting AI For Better Code
Domanda 1 di 8

Cosa dovrebbe indicare una chiara richiesta di generazione del codice oltre l’obiettivo generale?

Anteprima di ogni domanda8 domande

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

  1. Cosa dovrebbe indicare una chiara richiesta di generazione del codice oltre l’obiettivo generale?
    • A preferred language, framework, and test runner without describing the change
    • Relevant context, constraints, inputs and outputs, and expected behavior
    • Every neighboring module even when it does not affect the requested behavior
    • A general goal with no acceptance criteria or interface details
  2. Perché gli esempi concreti di input-output sono utili in un prompt di codifica?
    • They always reduce generated code size
    • They guarantee the code is secure
    • They remove the need for tests
    • They clarify expected behavior and edge cases
  3. Per riprodurre un particolare test fallito, quale contesto dovrebbe includere uno sviluppatore con il codice pertinente?
    • The failing input, expected result, observed error, and relevant function or API context
    • An expected result without the input that produced the failure
    • Only the test name and programming language, without the actual input or output
    • The full repository tree and stack trace, without identifying which test fails
  4. Quale sequenza rende più semplice verificare una richiesta di implementazione composta da più parti man mano che il lavoro procede?
    • Split the code by file, but defer tests and integration review until every part is generated
    • Have the assistant write separate components and infer success from its completion summary
    • Split it into small, testable tasks, review each result, then integrate the changes
    • Ask for an outline, then request all implementation at once and review only the final output
  5. Cosa aiuta a chiarire la richiesta di test insieme all'implementazione?
    • A test name without the inputs or expected result
    • A code-style preference unrelated to observable behavior
    • A list of implementation steps without saying what each step should produce
    • Expected inputs, outputs, and behavior that may be ambiguous
  6. Why should a developer name relevant library or framework versions?
    • It prevents the need to review dependency compatibility
    • Available APIs can vary, and suggestions should be checked against the installed version
    • It guarantees that code generated for the version has no defects
    • It ensures the assistant will use only APIs introduced after that version
  7. Before relying on a generated code change, which review sequence is strongest?
    • Review the diff, run relevant tests and checks, then assess security and compatibility
    • Review formatting and generated tests, then merge without running them
    • Run unit tests but skip checking interfaces and security-sensitive behavior
    • Ask the assistant to confirm its code is correct, then accept its test summary
  8. If an assistant’s first implementation is wrong, what is a useful next prompt?
    • Ask for a different implementation without identifying what failed
    • Remove the failing test so the implementation can proceed
    • Describe the observed discrepancy and provide a concrete failing case
    • Repeat the original request with the same context and no new evidence