-
Notifications
You must be signed in to change notification settings - Fork 560
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
Refactor to eliminate repetitive code. #783
Conversation
@@ -173,13 +173,15 @@ public string CreateApiUrl(Alias alias, string serviceName) | |||
// add entityid parameter to url for custom authorization policy | |||
public string CreateAuthorizationPolicyUrl(string url, int entityId) | |||
{ | |||
string qs = "entityid=" + entityId.ToString(); |
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.
What about
return url.Contains("?") ? "&" : "?" + "entityid=" + entityId.ToString();
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 go for the simple approach. I know what the code you pasted does, but IMO it's so complex for a one-liner.
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.
Not that complex ;) coz the first letter depends on whether the url contains query string or not
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.
Both ways are fine for me. The boss indicated a preference for the longer form.
#155 (comment)
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 prefer inline condition in such case but if the condition is complex or has nested conditions I may prefer if block for readability
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.
Thanks @jimspillane I thought I had read that somewhere. Plus at this point I don't want to change a lot of the code, meaning if it's an 'if block', then I will leave it as an if block.
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.
This take too long for a tiny change ;) could you please give a meaningful name instead of qs
and I'm fine with that
Simple improvement to keep the code DRY.