-
Notifications
You must be signed in to change notification settings - Fork 19
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
Create ByPropertyIdMap #479
Conversation
What are the responsibilities for this class? Just moving stuff around? What about methods that get or remove individual elements or groups? At the moment I find the class slightly confusing if one just looks at the code. For instance the field names are not entirely self explanatory. Somehow separating the operations on individual elements and on groups would be nice. In the past there was talk about adding a class for representing a group. (See the only not closed off item in #22) Have you thought about that? I'm thinking it might make such code a lot more obvious. |
The responsibility of this class is indeed to be able to move elements within a group and groups alltogether which is needed in the UI where we want to enable some moving functionality again.
For getting groups we have
Can you describe more detailed which field names are not entirely self explanatory and why? For me as I wrote the code it is a bit hard to identify where there might be issues.
I thought I did that by calling them
I think this class is fine the way it is. Statements, the main use case of this class, are stored as a flat list on items/properties (ie all |
e01251e
to
5c99a97
Compare
By this I mean that if one never saw the class before, the field names will not make clear what they contain. One can guess their role after also reading the method names, and confirm that guess after looking at their implementation a bit. At least that was how it went for me. looking at it again, this seems easy to fix: adding a short comment to the
Sure, you have separation by naming. The methods are on the same level though. This is not necessarily bad, and not something we can meaningfully discuss in isolation, as it needs to be compared to an alternative approach. So you think having a StatementGroup would not help improve the situation? To clarify, such a group would be responsible for its internal consistency, ie making sure there are no statements with a different property id in it. And it would hold methods to move statements within the group, while something else could then just deal with moving groups. I'm not opposed to this change, though am personally not going to merge this while I'm not more sure about the suitability, or lack thereof, of having a StatementGroup. If you do not want to investigate that, this is fine. If this topic gets stuck, I'll probably do that myself. |
Almost everywhere in the code we just deal with a list of statements so Given this single use case I think it would be too much overhead to create a new datastructure which is only useful in one single place. Of course we can split this class and have to separate classes to handle the indexing of property ids and the indexing within a group. However, I think to cover this rare usecase, this class is sufficient and we don't have to create new datastructures when there is no real need for them. |
Sounds reasonable. +1 |
So am I understanding your comments on #480 correctly by interpreting we might not need this to begin with? |
Not sure if I understand your comment correctly. We don't need this class if we just want to drop the |
This should finally act as a replacement for
ByPropertyIdArray
. It introduces a new form of indexing using two steps (therefore also two arrays in this class).First, there is an index for each property id, which states the order of per-property groups.
Second, there is an index for each
PropertyIdProvider
inside a per-property group.Both indices can be modified separately, using the move methods. It is also possible to add a new
PropertyIdProvider
. The finally usable result can be obtained using the methodgetFlatArray
which returns a simple list ofPropertyIdProvider
instances which are grouped by property id and in the order which has been specified using the move methods.Tracked in https://phabricator.wikimedia.org/T98375