Skip to content

Conversation

Juules32
Copy link
Collaborator

No description provided.

Copy link
Collaborator Author

@Juules32 Juules32 left a 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)
Copy link
Collaborator Author

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;
Copy link
Collaborator Author

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

Copy link
Collaborator

@AlbertRossJoh AlbertRossJoh Dec 20, 2023

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();
Copy link
Collaborator Author

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.

Copy link
Collaborator

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.

Copy link
Collaborator

@NatalieClaraPetersen NatalieClaraPetersen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SRP violation

Copy link
Collaborator

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

Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants