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

Rename IInheritable::InsertParent to improve clarity of intent #11820

Merged
1 commit merged into from
Nov 29, 2021

Conversation

lhecker
Copy link
Member

@lhecker lhecker commented Nov 24, 2021

This is a followup commit for 168d28b.
By renaming IInheritable::InsertParent(com_ptr) and
InsertParent(size_t, com_ptr) into AddLeastImportantParent(com_ptr)
and AddMostImportantParent(com_ptr) respectively, we can improve
the clarity of our code's intent without the need for comments.

PR Checklist

  • I work here
  • Tests added/passed

@lhecker lhecker added Area-CodeHealth Issues related to code cleanliness, linting, rules, warnings, errors, static analysis, etc. Area-Settings Issues related to settings and customizability, for console or terminal Product-Terminal The new Windows Terminal. labels Nov 24, 2021
@lhecker lhecker added this to the Engineering Improvements 2021 milestone Nov 24, 2021
@miniksa
Copy link
Member

miniksa commented Nov 24, 2021

I'm not sure I understand the parenting and priorities well enough to reason whether this is clearer or not. There's both a parent/child tree and an importance value assigned to each of them depending on whether they're push_front or push_back'd into the list of parents? Yes?

@lhecker
Copy link
Member Author

lhecker commented Nov 24, 2021

Yeah you could also call it PushParentBack and PushParentFront.
I prefer this renamed version for 2 reasons:

  • It's agnostic over the underlying container. The current API practically only works with a std::vector. But what if we want to reverse it, to have the most important one at the end?
  • Currently the code only calls either exactly InsertParent(somePointer) or InsertParent(0, somePointer). The positional parameter is actually never really used and thus can be replaced with something that's a bit more explicit.

@lhecker
Copy link
Member Author

lhecker commented Nov 24, 2021

I think the correct term for our inheritance tree is a "ordered anti-arborescence" -- a directed acyclic graph, where lists of paths are ordered and there's only one path at most between any 2 vertices.

The ordering is important, because if a settings item doesn't exist the "first" parent that has it set will win and return the value. That way the base layer is preferred over the defaults.

Copy link
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

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

Thank you!!!

@zadjii-msft zadjii-msft added the AutoMerge Marked for automatic merge by the bot when requirements are met label Nov 29, 2021
@ghost
Copy link

ghost commented Nov 29, 2021

Hello @zadjii-msft!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit a9c2db4 into main Nov 29, 2021
@ghost ghost deleted the dev/lhecker/iinheritable-cleanup branch November 29, 2021 20:40
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-CodeHealth Issues related to code cleanliness, linting, rules, warnings, errors, static analysis, etc. Area-Settings Issues related to settings and customizability, for console or terminal AutoMerge Marked for automatic merge by the bot when requirements are met Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants