0% found this document useful (0 votes)
4 views1 page

Clean Code Quick Reference

The document outlines key principles of clean code, including DRY, KISS, YAGNI, and the SOLID principles, which emphasize simplicity, reusability, and maintainability. It discusses design and structure concepts such as encapsulation, abstraction, and the importance of code quality through refactoring and naming conventions. Additionally, it covers architectural patterns and practices like the Repository Pattern and Dependency Injection to promote better organization and separation of concerns in software development.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Clean Code Quick Reference

The document outlines key principles of clean code, including DRY, KISS, YAGNI, and the SOLID principles, which emphasize simplicity, reusability, and maintainability. It discusses design and structure concepts such as encapsulation, abstraction, and the importance of code quality through refactoring and naming conventions. Additionally, it covers architectural patterns and practices like the Repository Pattern and Dependency Injection to promote better organization and separation of concerns in software development.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Clean Code Quick Reference

==========================

I. Core Principles
------------------
• DRY (Don’t Repeat Yourself): Avoid repeating code – reuse functions or modules.
• KISS (Keep It Simple, Stupid): Keep your design simple and clear.
• YAGNI (You Aren’t Gonna Need It): Don’t build features you don’t need yet.
• SOLID Principles:
- SRP: Single Responsibility Principle – one reason to change.
- OCP: Open/Closed Principle – open for extension, closed for modification.
- LSP: Liskov Substitution Principle – derived classes must be substitutable.
- ISP: Interface Segregation Principle – don’t force unused methods.
- DIP: Dependency Inversion Principle – depend on abstractions, not details.

II. Design & Structure


----------------------
• Encapsulation: Hide internal details, expose only necessary interfaces.
• Abstraction: Focus on essential behavior, hide complex details.
• Polymorphism: Same interface, different behavior.
• Inheritance: Share common behavior through class hierarchies.
• Composition over Inheritance: Prefer combining objects over deep inheritance.
• Immutability: Objects whose state cannot change after creation.

III. Code Quality & Organization


--------------------------------
• Refactoring: Improve internal structure without changing behavior.
• Code Smells: Signs of poor design (e.g., duplication, long methods).
• Naming Convention: Consistent naming (camelCase, PascalCase).
• Separation of Concerns: Divide code by purpose and responsibility.
• Loose Coupling: Reduce dependencies between modules.
• High Cohesion: Related functionality stays together.
• Testability: Easy to test and verify code.
• Readability: Easy to understand for any developer.
• Maintainability: Easy to modify and extend safely.

IV. Patterns & Architecture


---------------------------
• Design Patterns: Proven solutions (Singleton, Factory, Observer, etc.).
• Repository Pattern: Separate data access from logic.
• Service Layer: Business logic layer outside controllers.
• Dependency Injection (DI): Pass dependencies instead of creating them.
• DTO (Data Transfer Object): Transfer structured data between layers.
• Mapper: Convert data between layers (Model ↔ DTO).
• Controller Fatigue: Overloaded controllers – avoid heavy logic in them.

You might also like