-
Notifications
You must be signed in to change notification settings - Fork 0
Add some comments #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
@@ -14,6 +14,7 @@ class DjangoStorage(Storage): | |||
"""Adapter to use Django ORM as a storage backend.""" | |||
|
|||
def create_user(self, user, password): | |||
# not injecting repo makes it less explicit when testing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean what you call repo_provider
in your code? So the User.objects
here?
@@ -22,6 +23,7 @@ def create_user(self, user, password): | |||
django_user = accounts_models.User.objects.from_entity(user) | |||
django_user.set_password(password) | |||
django_user.save() | |||
# nizar: unnecessary coupling with the return from the repo; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, I prefer a function that takes a model as an argument and returns the entity.
@@ -98,6 +100,7 @@ def delete_board_user(self, user_id, board_id): | |||
raise self.DoesNotExist('User {} is not joined to board {}'.format(user_id, board_id)) | |||
|
|||
django_board_user.delete() | |||
# nizar: interesting choice here, not sure why it returns this kind of object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this should return an entity to be consistent right?
@@ -5,6 +5,7 @@ | |||
|
|||
from .storage import Storage | |||
|
|||
# nizar: very cool exercise for leveraging the advantages of having a common interface for a repo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this makes it clear why you want to abstract the repository so you can switch between django storage and memory storage easily and test the business rules.
Besides my comments and apart from naming the only thing that struct me a bit oddly was the folder structure and file naming. But I see many advantages in having the Entity model folder as the root folder for all the interactors, repository and whatnot. I'd prefer to have the files for each use case/interactor available separately though, for the same reason that I liked the way the Entity named the root folder: visibility over what those files responsibilities.
As I said in the comments, I also see advantages in having more comprehensive and better split tests. Here's a very nice article from Martin Fowler on tests architecture: https://martinfowler.com/articles/microservice-testing/meta-image.phttps://martinfowler.com/articles/microservice-testing/meta-image.png