cpmbits / cpmbits/cpm

Avoid forcing dependency injection on class creation by using default parameter values

Open
#239 0 comments 0 reactions 0 assignees View on GitHub
concern
Dominant language
Python
Stars
11
Forks
2
PR merge metrics
No merged PRs in 30d

Description

The current dependency injection model forces to inject the dependencies on all constructors. While useful for the tests, it's cumbersome and inconvenient for the code. Instead, the parameters could be assigned a default value like so:

```python
class CreationService:
def __init__(self, project_loader=ProjectLoader(), template_downloader=TemplateDownloader()):
self.project_loader = project_loader
self.template_downloader = template_downloader
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.