In the Log
method there is the parameter of type HttpClient
. The function only uses the parameter to access the property BaseAddress
, which is a Uri
.
private void Log(string verb, HttpClient httpClient) {
var url = httpClient.BaseAddress.ToString();
Logging.LogInfo(GetType().Name, $"Iniciou requisição HTTP {verb} no endereço {url}");
}
Since everyone calling Log(string, HttpClient)
also has access to HttpClient.BaseAddress
, the Log
method might look like this:
private void Log(string verb, string url) {
Logging.LogInfo(GetType().Name, $"Iniciou requisição HTTP {verb} no endereço {url}");
}
and who calls you:
Log(HttpVerbs.Post, anotherHttpClient.BaseAddress.ToString());
In this way, I would not pass the most complex object of type HttpClient
but only what interests me, which is a string
. I did it first, passing HttpClient
in case I need more HTTP client information in the log in the future.
Considering HttpClient
the most complex type and string
the simplest, what I want to know is whether there is difference in performance and memory usage in both ways.
Is it the same thing to do with the complex object and the simplest object? Is it going to consume more or less memory? How is this handled in .NET?