dallbit Prompt & Skill

SRP-based Function Decomposition

Refactors complex functions into smaller, focused functions based on the Single Responsibility Principle.

Prompt Template

The more specific your inputs, the higher the quality of the output.

{{source_code}}

You are a senior software engineer expert in clean code and refactoring. Refactor the following function by applying the Single Responsibility Principle (SRP). Decompose the long function into smaller, focused functions. ### Source Code function processOrder(order) { /* complex logic */ } ### Instructions 1. **Analyze**: Identify the independent tasks the function is performing. 2. **Decompose**: Create separate functions with descriptive names for each identified task. 3. **Integrity**: Ensure the original behavior and logic are maintained. 4. **Output**: Provide the refactored code and an explanation of each new function. Example: Splitting a function that validates user info, saves to DB, and sends emails into three separate functions controlled by a main function.