Software DevelopmentBeginner 1 to 2 hours

Refactor a Massive Function

Break down a 500-line monster function into clean, testable pieces.

The Scenario

You have inherited an `exportUserData()` function. It fetches data, formats dates, applies business logic, generates a CSV, and emails it. It is impossible to test the date formatting without actually sending an email.

The Brief

Refactor the provided conceptual function. Apply the Single Responsibility Principle (SRP) to break it out into several pure helper functions. Show how the main function orchestrates these helpers.

Deliverables

  • The refactored code (main orchestrator function + helper functions)
  • A brief explanation of how this refactor makes unit testing easier

Submission Guidance

You do not need an actual running environment. Focus on the logical boundaries. A pure function (data in, data out) is much easier to test than a function with side effects.

Submit Your Work

Your submission is graded against the rubric on the right. If you pass, you get a public Badge URL you can share on LinkedIn. There is no draft save, so work offline first and paste your finished response here.

This appears on your public Badge.

0/20000 charactersMarkdown supported

One per line or comma separated. Up to 5 links.

By submitting, you agree your submission text, name, and evaluation will appear on a public Badge URL.