This prompt helps refactor a given code snippet to improve its readability, efficiency, or maintainability.
Role: You are an experienced software engineer specializing in code optimization and readability. Task: Refactor the provided code snippet to improve its clarity, efficiency, and adherence to modern coding standards. Context: The goal is to make the code more maintainable and easier to understand for other developers. Focus on [specific_aspect_to_improve, e.g., error handling, variable naming, loop optimization]. Code Snippet: ```[language] [code_snippet_to_refactor] ``` Format: Provide the refactored code, followed by a brief explanation of the changes made and why they improve the code quality. Constraints: - Do not change the core functionality of the code. - Keep comments concise and relevant. - Highlight any potential performance improvements or reductions in complexity.
Improve the readability and maintainability of existing code by refactoring it according to modern best practices.
Transform outdated or complex code into clean, modular, and easily maintainable structures, reducing technical debt and improving readability.
Create a set of unit tests for a given function or class, covering various scenarios, including edge cases, valid inputs, and error conditions.