Template Method page#27
Conversation
There was a problem hiding this comment.
Pull request overview
This PR implements a comprehensive documentation page for the Template Method design pattern, following the established structure and conventions used across other behavioral pattern pages in the repository.
Key Changes:
- Adds complete Template Method pattern documentation with problem statement, solutions, metaphors, and real-world examples
- Includes TypeScript and Python code samples demonstrating the pattern with a data processing example
- Provides an interactive playground component for users to experiment with the pattern
|
|
||
| def transform(self, data): | ||
| print("🔄 Transforming JSON to normalized format") | ||
| import json |
There was a problem hiding this comment.
The json module is imported again here, but should be imported only once at the top of the file (after line 199). Remove this duplicate import statement.
| class JSONProcessor(DataProcessor): | ||
| def validate(self, data): | ||
| print("✅ Validating JSON format") | ||
| import json |
There was a problem hiding this comment.
The json module should be imported at the top of the file (after line 199, with the other imports) rather than inside the method. Import statements inside methods are considered poor practice in Python as they can impact readability and performance. The same applies to the duplicate import on line 251.
Move import json to line 200 (after from abc import ABC, abstractmethod) and remove the imports from lines 242 and 251.
Implement page