-
Notifications
You must be signed in to change notification settings - Fork 80
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
removal of potentially harmful parameter. #91
base: master
Are you sure you want to change the base?
Conversation
I managed to build an inconsistent graph as the edge.directed information was overwritten by addEdge(_, directed:). Now, the directed parameter is no longer needed. Instead, the information is taken from the Edge parameter.
I should mention, that I only removed the parameter where the information is already provided via Edge. In other cases, like convience addEdge methods, it is kept. |
This is, unfortunately, a breaking change as I changed the Graph protocol. |
Thanks for the contribution. This does potentially make sense but yeah unfortunately is a breaking change. One way to make it a non-breaking change would be to have new one parameter methods for |
I think I managed to make it a non-breaking change for most use cases. The "only" time the code will now break is if someone else implemented the Graph protocol separately. |
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.
A couple of minor suggestions on the last commit, but this seems like a smart change, and the deprecation is a nice way to go about it.
Sources/SwiftGraph/Graph.swift
Outdated
@@ -39,6 +39,11 @@ extension Graph { | |||
public var edgeCount: Int { | |||
return edges.joined().count | |||
} | |||
|
|||
@available(*, deprecated, renamed: "addEdge", message: "Use the addEdge method without the additional directed parameter instead, as the Edge contains already the information about direction. A double specification can only result in inconsistencies and errors.") | |||
func addEdge(_ e: E, directed: Bool = false){ |
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.
func addEdge(_ e: E, directed: Bool = false){ | |
func addEdge(_ e: E, directed: Bool = false) { |
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.
actually, you found an outdated version. I removed the default value (false) in the latest version.
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.
Without the default value there is a more clear distinction between the one-parameter version and the 2-parameter. And there is no confusion that you use the one-parameter version when you leave out the default parameter - and not using the default value
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.
formatting updated.
Co-authored-by: Zev Eisenberg <[email protected]>
# Conflicts: # Sources/SwiftGraph/Graph.swift
sorry, KneupnerTrackunit is my alterEgo. Not sure why the last commits where under that name. |
I managed to build an inconsistent graph as the edge.directed information was overwritten by 2nd parameter of addEdge(_, directed:). Now, the directed parameter is no longer needed. Instead, the information is taken from the Edge parameter.
One source of potential problems less.