Skip to content
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

Add TryGetX method to all algorithm implementations for external access to values stored in dictionaries #15

Open
SimonTC opened this issue Aug 8, 2020 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@SimonTC
Copy link

SimonTC commented Aug 8, 2020

As discussed in #13 all algorithm objects currently are leaking implementation details by making the dictionaries public properties.
To be able to depreciate the direct access to the dictionaries in the future, new methods should be added to the algorithms for getting values in the dictionaries.
In some algorithm objects there already is a TryGetColor for getting vertex colors. This approach should be used in all algorithms.

One thing to consider is if we also should have a TryGetXWithDefaultValue where a default value is returned if the vertex isn't found. It could cut down on boiler plate code for callers if they always want a value, but I'm not sure how important this is right now.

@KeRNeLith
Copy link
Owner

Concerning the TryGetXWithDefaultValue we can also think about two methods in such situation meaning;

  • TryGetX(...) (would throw for example with vertex not found and no data associated)
  • TryGetX(..., ... defaultValue) (no throw, or maybe if the vertex is not part of the treated graph)

@SimonTC
Copy link
Author

SimonTC commented Aug 9, 2020

When using the TryGetX naming I don't think we should throw exceptions since that would not be in line with how the functionality works with standard dictionaries. I do agree that setting the default value as part of the TryGetX makes sense.

Question is if we also should have a GetX method that does throw if the key doesn't exist?
So we have both TryGetX that never will throw and TryX that does throw if the vertex doesn't exist / isn't accessible.

@KeRNeLith
Copy link
Owner

Yeah you're right, that better fit the TryGet approach. In this case there are some implementation that may need to be updated. I was thinking about TryGetColor.

Considering the fact that TryGet does not throw having a Get version seems cool, like we have Parse and TryParse etc.

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

No branches or pull requests

2 participants