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

BHoM_Adapter: refactoring- should all IBHoMObjects implement a default "base" comparer that when checking for equality first of all looks at the GUID? #99

Open
Tracked by #84
alelom opened this issue Jun 7, 2019 · 2 comments
Assignees
Labels
type:question Ask for further details or start conversation

Comments

@alelom
Copy link
Member

alelom commented Jun 7, 2019

Because I am not sure that the following is something we want (Push with RobotAdapter, which uses comparers):

image
here node duplicates are correctly filtered out -- but that just because they have a comparer implemented.

image
here bars duplicates are not filtered out -- even though they are have the same GUID (i.e. BHoM knows they are the same bar)

Implementing a default base comparer for IBHoMObjects that uses GUID for equality would solve this without having to manually implement a comparer for every type.
Not sure about potential side-effects though. Replace() and consequently Push, Pull etc should all work as usual, I think.

@IsakNaslundBh @al-fisher @epignatelli @adecler

@alelom alelom added the type:question Ask for further details or start conversation label Jun 7, 2019
@alelom alelom changed the title BHoM_Adapter: refactoring-all IBHoMObjects should implement a "base" comparer that when checking for equality first of all looks at the GUID? BHoM_Adapter: refactoring- should all IBHoMObjects implement a "base" comparer that when checking for equality first of all looks at the GUID? Jun 7, 2019
@alelom alelom changed the title BHoM_Adapter: refactoring- should all IBHoMObjects implement a "base" comparer that when checking for equality first of all looks at the GUID? BHoM_Adapter: refactoring- should all IBHoMObjects implement a default "base" comparer that when checking for equality first of all looks at the GUID? Jun 7, 2019
@alelom alelom self-assigned this Jun 7, 2019
@IsakNaslundBh
Copy link
Contributor

First, I am not sure if I think the above behaviour is a bug. As you stated, the bars do not have a comparer implemented, hence the whole comparison is skipped. might be cases (not for structural packages maybe, but for other things) where we want to be able to push the same item twice for whatever reason, so no-comparer -> no culling I think is expected behaviour to some extent.

If we want to add a default comparer for the adapters I think a Guid comparer could work. Only thing to make sure is that the Guids are dealt with as we want in everything done before, leading up to the adapters. As we have not relied that heavily on the Guids up until this point it is probably worth checking the impact it has, but again, could work.

@alelom
Copy link
Member Author

alelom commented Jun 10, 2019

Thanks for the reply @IsakNaslundBh!

First, I am not sure if I think the above behaviour is a bug. As you stated, the bars do not have a comparer implemented, hence the whole comparison is skipped. might be cases (not for structural packages maybe, but for other things) where we want to be able to push the same item twice for whatever reason, so no-comparer -> no culling I think is expected behaviour to some extent.

Sure, I never called that a bug because I know it's a design behaviour. I'm just not sure it's the one we really want!
I just don't think the default behaviour should allow you to export the exact same item (bar or anything else) twice, which I think in 99% of cases is simply a mistake/overlook -- I can't even think of any case where anybody might want that intentionally. However, I'm not saying to remove this completely.
Where that is an intended action, I think the Adapter should rather 1. Prompt that it has found duplicates based on GUID 2. give the possibility to actually do it (perhaps in the config).
I think that something like that would be of help to beginners.

If we want to add a default comparer for the adapters I think a Guid comparer could work. Only thing to make sure is that the Guids are dealt with as we want in everything done before, leading up to the adapters. As we have not relied that heavily on the Guids up until this point it is probably worth checking the impact it has, but again, could work.

Agreed. As I said when we chatted, we have the GUIDs, why not trying to use them -- subject to proper checks of course :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:question Ask for further details or start conversation
Projects
None yet
Development

No branches or pull requests

2 participants