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

Spatial_Engine: Add HasMergeablePropertiesWith method #1630

Merged
merged 7 commits into from
Apr 15, 2020

Conversation

kThorsager
Copy link
Contributor

@kThorsager kThorsager commented Mar 31, 2020

Issues addressed by this PR

Closes #1629
This adds a method which compares the properties of IElements, atm only does base comparison and returns false for objects of equal type which do not have a method specified.

Test files

https://burohappold.sharepoint.com/:f:/s/BHoM/EgIee2Xt7DJFu--Isb6FWAkBZot7MPpF8YhyOAKcKy9r8Q?e=sIuvRw

Changelog

Additional comments

Feels like I'm using the Interface method in the exact opposite manner compared to how they're usually used, but I think it's still how we'd want it(?)

does not overlap with #1623

not sure when it would be used, but no reason not to add it
@pawelbaran
Copy link
Member

Initial comment: if CI/CD is scraping project names from PR titles, then there is a typo in there 🐒

@kThorsager kThorsager changed the title Spatail_Engine: Add IsEqualProperties method Spatial_Engine: Add IsEqualProperties method Mar 31, 2020
return false;

// look for a specific comparing method
object result = Reflection.Compute.RunExtensionMethod(element, "IsEqualProperties", new object[] { other });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wont this lead to stack overflow given that the method is called the same thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, you'd think so, but the test file runs and passes that part, but I'll change it to be on the safe side 👍

@kThorsager kThorsager requested a review from IsakNaslundBh April 1, 2020 09:47
Copy link
Member

@pawelbaran pawelbaran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there is a typo in one of the method names - see code comment. Besides, not sure if Is would be my first choice for prefix here. What about HasEqualProperties?

@al-fisher @adecler

/**** Private Methods ****/
/******************************************/

private static bool IIIsEqualProperties(this IElement element, IElement other)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

III?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid stack overflow as I have methods calling this method and this method should not call it self or the previous ones

See:
#1630 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, makes sense, but looks weird. Maybe it could be done somehow neater (can't come up with anything nice myself though 🐒)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think a different name is the way to go without repeting the code or just going with input: (IElement, IElement)

some suggestions if it's the double I which is disturbing

IsEqualPropertiesDispatcher
IsEqualPropertiesProgram
IsEqualPropertiesMeat

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IsEqualPropertiesInterface?

@kThorsager
Copy link
Contributor Author

kThorsager commented Apr 8, 2020

Looks like there is a typo in one of the method names - see code comment. Besides, not sure if Is would be my first choice for prefix here. What about HasEqualProperties?

Yes, I'm open for other names.

An other suggestion is HasMergebleProperties

@pawelbaran
Copy link
Member

Looks like there is a typo in one of the method names - see code comment. Besides, not sure if Is would be my first choice for prefix here. What about HasEqualProperties?

I'm open for other names, other suggestion is HasMergebleProperties

Even better! Possibly we could have 2 methods, one checking whether the properties are equal and the other checking if they can be merged. Something for Diffing_Engine, @alelom?

Dropping one more idea: CanMergeProperties

@pawelbaran pawelbaran dismissed their stale review April 8, 2020 10:14

Dismissing my change request and turning into comments.

@al-fisher
Copy link
Member

I like HaveMergebleProperties as a naming convention. "Have" though rather than "Has" as is operating on a pair of objects.

@kThorsager kThorsager changed the title Spatial_Engine: Add IsEqualProperties method Spatial_Engine: Add HaveMergebleProperties method Apr 8, 2020
@kThorsager kThorsager requested a review from IsakNaslundBh April 8, 2020 14:44
Copy link
Contributor

@IsakNaslundBh IsakNaslundBh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think the code generally looks fine now. File needs to be renamed HaveMergebleProperties though.

@FraserGreenroyd
Copy link
Contributor

/azp run BHoM_Engine.CheckCompliance

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@adecler adecler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • The file name is now incorrect.
  • Shouldn't it be mergeable instead of mergeble?
  • I am not convinced by the use of have here. The method is applied to the this argument only not to all the inputs together (i.e. x.HasMergeableProperties(y), not (x&y).HaveMergeableProperties()). I would be fine with x.HasMergeablePropertiesWith(y) though.

@kThorsager
Copy link
Contributor Author

  • The file name is now incorrect.

Yes, fixed

  • Shouldn't it be mergeable instead of mergeble?

Yes, fixed

  • I am not convinced by the use of have here. The method is applied to the this argument only not to all the inputs together (i.e. x.HasMergeableProperties(y), not (x&y).HaveMergeableProperties()). I would be fine with x.HasMergeablePropertiesWith(y) though.

Maybe, will hold off on action as it sounds like there should be some discussion and am unsure myself

@al-fisher
Copy link
Member

I am not convinced by the use of have here. The method is applied to the this argument only not to all the inputs together (i.e. x.HasMergeableProperties(y), not (x&y).HaveMergeableProperties()). I would be fine with x.HasMergeablePropertiesWith(y) though.

Yes - I like x.HasMergeablePropertiesWith(y) more @adecler
Great point. It was indeed the this keyword that was throwing me to start with. “Have” did not really scan perfectly. Appending “With” is neat and could be a pattern to reuse elsewhere for clarity.

@kThorsager kThorsager changed the title Spatial_Engine: Add HaveMergebleProperties method Spatial_Engine: Add HasMergeablePropertiesWith method Apr 14, 2020
Copy link
Member

@adecler adecler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM on the side of the code.
Probably good to have another approval from someone involved in teh Spatial toolkit itself

@adecler
Copy link
Member

adecler commented Apr 15, 2020

/azp run BHoM_Engine.CheckInstaller

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@IsakNaslundBh IsakNaslundBh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now all looks fine!

@IsakNaslundBh IsakNaslundBh merged commit 9b2e0a0 into master Apr 15, 2020
@IsakNaslundBh IsakNaslundBh deleted the Spatial_Engine-#1629-IsEqualProperties branch April 15, 2020 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature New capability or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spatial_Engine: IsEqualProperties
6 participants