Single Responsibility (one purpose per class), Open/Closed (open for extension, closed for modification), Liskov Substitution (subtypes must be substitutable), Interface Segregation (specific interfaces), Dependency Inversion (depend on abstractions). Implement using proper class design, inheritance, and abstractions.
Follow AAA pattern (Arrange-Act-Assert), use clear test names. Implement proper test isolation. Consider test readability. Handle test data properly. Document test cases. Maintain test suite.
Comment why, not what. Keep comments updated with code. Use proper inline documentation. Consider self-documenting code. Document complex algorithms. Avoid redundant comments. Keep comments concise.
Make messages clear, actionable. Include relevant context. Consider user perspective. Handle internationalization. Document error conditions. Implement proper error categorization. Consider error recovery.
Use deprecation warnings, provide migration path. Document deprecation timeline. Maintain backward compatibility. Consider impact on users. Implement proper versioning. Handle removal process.
Use descriptive names, follow conventions. Consider scope visibility. Use proper prefixes/suffixes. Maintain consistency. Document naming patterns. Consider international aspects.
Minimize global state, use dependency injection. Consider thread safety. Implement proper access patterns. Document global dependencies. Consider testing implications. Handle state initialization.
Follow PEP 257: describe purpose, parameters, return values, exceptions. Use consistent format (Google, NumPy, reStructuredText). Include examples when appropriate. Consider doctest integration. Keep updated with code changes. Essential for code understanding and maintenance.
Pass dependencies as parameters, use dependency containers, implement factory patterns. Consider interface-based design. Handle dependency lifecycle. Use proper abstraction. Consider testing implications. Implement proper configuration management.
Use proper package hierarchy, separate concerns, implement clear imports. Follow standard project layout (setup.py, requirements.txt, docs/, tests/). Consider module organization. Implement proper configuration management. Document project structure.
Functions should be small, do one thing, have clear names. Use proper parameter design, avoid side effects. Consider return value clarity. Implement proper validation. Document function behavior. Consider error cases.
Use appropriate log levels, implement structured logging. Consider log format, destination. Handle sensitive data appropriately. Implement proper error reporting. Consider log rotation, retention. Document logging conventions.
Follow single responsibility, use proper inheritance. Implement encapsulation. Consider composition over inheritance. Document class behavior. Handle initialization properly. Consider class evolution.
Use proper wrapper functions, maintain function metadata. Handle arguments properly. Consider chaining decorators. Document decorator behavior. Consider performance implications.
PEP 8 defines Python's style guide: indentation (4 spaces), line length (79 chars), naming conventions (snake_case for functions/variables, PascalCase for classes), import organization. Ensures code readability and consistency across Python community. Key for maintainability and collaboration.
Catch specific exceptions, not bare except. Use context managers for resource cleanup. Implement proper error hierarchy. Log exceptions appropriately. Consider error recovery strategies. Don't suppress exceptions without good reason. Document exceptional cases.
Extract common code into functions/classes. Use inheritance and composition appropriately. Implement utility modules. Consider code reusability. Balance DRY with readability. Use proper abstraction levels. Consider maintenance implications.
Check style consistency, proper error handling, test coverage. Review documentation, performance implications. Consider security aspects. Look for code smells. Provide constructive feedback. Document review process.
Use configuration files, environment variables. Implement proper validation. Handle different environments. Consider security implications. Document configuration options. Implement proper defaults.
Use factory methods for object creation, implement proper initialization. Consider inheritance hierarchy. Handle configuration. Document factory behavior. Consider error cases.
Profile before optimizing, focus on bottlenecks. Consider algorithmic efficiency. Use appropriate data structures. Handle memory usage. Document optimization decisions. Consider maintenance implications.