Skip to content

Conversation

@frederickrogan
Copy link
Contributor

I have rewritten a version of the standard requester by attempting to separate its responsibilities into new classes. Benefits are improved testability (httpclient can be injected) and I think it's cleaner.

I'd appreciate feedback. If positive I'll continue and attempt to replace the other requesters.

Copy link
Contributor

@JanOuborny JanOuborny left a comment

Choose a reason for hiding this comment

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

Looks very good 👍 I like all of your changes, but implementing it in the whole project might take a while. I propose we move these changes into a new branch until we have a new working implementation of the RateLimitedRequester, which matches this pattern. When this is done, we could start pushing this into the develop branch.

public async Task<T> DeserializeToAsync<T>(HttpResponseMessage message)
{
var json = await message.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<T>(json);
Copy link
Contributor

Choose a reason for hiding this comment

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

Couldn't you run this in a task?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did not see the benefit. After a bit of googling I have changed my mind and will put run it in one. Thanks

namespace RiotSharp
{
public class StatusRiotApi : IStatusRiotApi
public partial class StatusRiotApi : IStatusRiotApi
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you want to split this into two partial classes? I don't think this is really needed.

Copy link
Contributor Author

@frederickrogan frederickrogan Oct 3, 2017

Choose a reason for hiding this comment

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

I had considered placing the second partial class in a separate file beside the original named "StatusRiotApiSingleton.cs."

I preferred separating the logic of the class from the method of creating/getting an instance. But maybe partial classes aren't the best way of doing this? Does splitting them up not provide some benefit in readability?

Copy link
Contributor

@JanOuborny JanOuborny Oct 4, 2017

Choose a reason for hiding this comment

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

You can split them up into two different files. However, spliting the class into partial classes inside the same file doesn't really provide a benefit in my eyes. You can achieve the same effect with regions, which in my opinion, is cleaner.

{
public interface IRequestCreator
{
HttpRequestMessage CreateGetRequest(Region region, string apiEndpoint, List<string> addedArguments, bool useHttps = true);
Copy link
Contributor

@JanOuborny JanOuborny Oct 3, 2017

Choose a reason for hiding this comment

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

Here might be needed functions for creating PUT and POST requests. They will be needed for the tournament endpoint.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. I hadn't written them yet since this only covered the standard requester which is only used by the status api. I'll include it in the branch you suggested.

@JanOuborny
Copy link
Contributor

As far as I can see all changes are in #481. Therefore, I am closing this PR and the discussion can continue in #481.

@JanOuborny JanOuborny closed this Oct 4, 2017
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.

2 participants