-
Notifications
You must be signed in to change notification settings - Fork 1
Topic/fix stuff #173
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: main
Are you sure you want to change the base?
Topic/fix stuff #173
Conversation
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.
These are great changes. I have added a few minor comments.
|
||
public CheepRepository(ChirpDBContext db, IFollowRepository followRepository) |
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.
skide godt, nu er repositories ikke coupled!
@@ -25,13 +27,14 @@ public void AddLike(Like like) | |||
// Check if like already exists | |||
if (LikeExists(like)) | |||
{ | |||
throw new Exception("Cheep is already liked by author!"); | |||
// This is more resilient idempotency wise since we could get duplicate requests across the network | |||
return; |
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.
Please explain this to me like I'm 5
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.
When I send mail via the postal service they can duplicate my letter by accident sending it with two different deliverers. When that happens they might both get it to me, but it does not make sense to call the post office and yell at them for receiving it twice, we just throw the second letter out.
return author ?? throw new Exception("Author doesn't exist!"); | ||
var author = RepositoryManager.AuthorRepository.FindAuthorsByName(authorName); | ||
var enumerable = author.ToList(); | ||
return !enumerable.Any() ? RepositoryManager.AuthorRepository.CreateAuthor(new Author{Email = "", Name = authorName}) : enumerable.First(); |
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.
I personally disagree with creating new author if not found.
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.
Well when do we otherwise create authors? I get what you're saying and I agree that it is the best option, but right now we throw exceptions each time a new user logs into our service.
Co-authored-by: Juules32 <benjaminbyvej@gmail.com>
…3/Chirp into topic/fix-stuff
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.
SRP violation
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.
Single Responsibility Principle violated in CreateAuthor returning an author
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.
How does that violate SRP? Returning the object created should not be problematic. Though I agree the function name should rather be CreateAndStoreAuthorIfNotExist
. Also it actually violated SRP from the beginning as it both checked that an author existed, created the object and stored the object.
But I personally do not think that is problematic as long as the documentation supports what is written. Or as you see the proper function name which states what the function does.
No description provided.