Exercises

These exercises practice the spec-driven workflow on the absenteeism project and on adjacent problems. Each exercise extends an artifact built in this chapter or asks you to apply the same discipline to a new context.

14.6.2 1. Critique a vague request

The HR director’s original email — “We’ve had a lot more unplanned absences over the last couple of years. Can you take a look at the data and tell us what’s going on?” — would not survive a junior consulting interview. Rewrite the email as a complete problem statement with three answerable key questions, two acceptance criteria, and at least one explicit constraint. Compare your version with the BRS in Section 2 and identify what your phrasing captures that Section 2 misses, and vice versa.

14.6.3 2. Build a data dictionary

Choose a built-in R dataset (mtcars, iris, or diamonds) and write a complete data dictionary in the format used in Section 2 — variable name, type, range or values, and plain-language description. Include at least one quality criterion per variable. Render the dictionary as a kable table.

14.6.4 3. Use AI to draft a spec

Pick a real or hypothetical BI project (e.g., predicting student retention, forecasting holiday sales). Write five bullet points of discovery notes, then prompt an AI assistant using the first-draft prompt template from Section 3. Review the output, identify three weaknesses, and write the follow-up prompts that would fix them. Submit the original prompt, the AI’s draft, your critique, and the revised draft.

14.6.5 4. Add a validation check

Extend validate_data_quality() with a new check enforcing one of the following: (a) Distance from Residence to Work is between 5 and 60 km; (b) every employee has at least one absence event; (c) Age is consistent with Service time — an employee cannot have more years of service than they have years above 18. Run the extended suite and confirm that the new check produces a PASS row.

14.6.6 5. Spec-drive your own project

Choose a small dataset of your own — a course-related project, a Kaggle dataset, or a public-data download — and walk it through the spec-driven workflow end-to-end: write a BRS, write a data spec, build at least one deliverable in R, and validate the deliverable against the spec with executable checks. Submit the spec, the analysis, and the validation output as a single R Markdown or Quarto document.