PromptsVault AI is thinking...
Searching the best prompts from our community
Searching the best prompts from our community
Prompts matching the #clean-code tag
Write maintainable code using SOLID principles. Principles: 1. Single Responsibility (class has one reason to change). 2. Open/Closed (open for extension, closed for modification). 3. Liskov Substitution (subclasses should be substitutable for base classes). 4. Interface Segregation (many specific interfaces > one general). 5. Dependency Inversion (depend on abstractions, not concretions). Additional: DRY (Don't Repeat Yourself), KISS (Keep It Simple), YAGNI (You Aren't Gonna Need It). Use meaningful names. Functions should be small (<20 lines). Comments explain why, not what. Refactor regularly. Code is read 10x more than written.
Refactor code safely and effectively. Common refactorings: 1. Extract Method (long function → smaller functions). 2. Rename Variable (unclear → descriptive). 3. Extract Class (large class → multiple focused classes). 4. Inline Method (unnecessary abstraction). 5. Replace Magic Numbers with Constants. 6. Introduce Parameter Object (long parameter lists). 7. Replace Conditional with Polymorphism. When to refactor: before adding features, during code review, when fixing bugs. Red-Green-Refactor cycle. Use IDE refactoring tools. Keep tests green. Small steps. Commit after each refactoring. Based on Martin Fowler's 'Refactoring' book.