PromptsVault AI is thinking...
Searching the best prompts from our community
Searching the best prompts from our community
Prompts matching the #solid 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.
Explain the "Single Responsibility Principle" (SRP) from the SOLID principles of object-oriented design. Provide a simple "before" code example in C# or Java that violates SRP, and then show an "after" example that refactors the code to adhere to the principle.