-
Notifications
You must be signed in to change notification settings - Fork 18
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
Split XML node data of ElementInfo into NodeInfo, ElementInfo, and TextInfo #163
Comments
Initial thoughts:
|
Prefer to leave it so there is no need (if necessary) to create backward compat problems or allow extended behavior, should we or another developer decide to change it, given how little that behavior costs to cast.
Will make an attempt to generate a content string every time by reading out the element's text children.
The Try methods are to be the core functionality for those behaviors that can be extended and detect if the values were actually changed. |
The problem isn't casting, the problem is that, say, a
Propose to rename to
I still don't see a case where someone would expect them to fail. The point of |
No it doesn't, while in a technical sense a TextNode could be attempted to be assigned as a parent it doesn't support child nodes and its trivial to make TrySetParent fail in the case you try. That's part of what TrySetParent can account for. If we want it to throw an exception we could but I'd say TrySetParent is good enough. If necessary could have NodeInfo use a
Its not going to be a getter method, it will regenerate it every time, reason I didn't want to call it a Get is specifically because it should not be treated as equal to Content as it currently stands. Perhaps I can change the name to
Its for the sake of extensibility, we can define whether something has failed without describing what specifically should happen as a result of failure. |
If the restriction is type-based, why aren't we expressing that using the type system?
Given that there's a couple more requirements for a thing to support children, that should probably be a separate interface.
Getter methods can in principle still regenerate every time.
I'm not suggesting we make it a property. Having it as a separate method, even with a
I still don't see a case where someone would expect them to fail. When would setting an attribute value fail? |
Because its not.
I guess.
If it wasn't O(n) for the dictionary, but there is no expectation that its a simple getter method. If it was merely generating something simple and quickly I'd have made it a property getter, but that's not its intent.
Addressed above.
But it does so every time. Every time its called it will read from the Children and combine all the text nodes with
For extensibility reasons say we or someone else wanted to build an element that was readonly, setting an attribute would most certainly want to fail but it still be more convenient for someone to have it as an ElementInfo for general use. Since it costs near nothing to have this modularity and we can't predict exactly what people may do, better to create default behavior with the classes and leave the rest to inheritance implementations should people so want. |
We literally have two types here, only one of which can be a parent node. If someone else wants to extend this system, they have to create their own type. I'd say that's pretty type-based.
It being O(n) is a valid concern here, though I've seen O(n)
That's kind of my point -- making it not a property getter already conveys that it doesn't follow the the usual property rules. Not that I'm against further making it clear that it's not a simple operation, but:
It still doesn't generate anything. It only really collects a bunch of values and concatenates them into a string. That's not really generative.
That's a fair point. I'm not quite sure why you'd want to extend this system with a readonly element &c, but it's conceptually sound.
*can't |
Note that this would be generative because the value doesn't exist beforehand and it will make the value exist afterwards, and it would redo all that work if called again, it will not save the value. Creating a new string from a list of data on every call would definitely fit into the category of generative. |
I disagree on that -- the data is already there, just not as one thing. Collative, not generative. |
That's a semantics debate, the fact of the matter is that new data will be produced from existing data every time, (just because not all the data is being recreated does not constitute whether its generative, its specific to what's happening which is generating the content from the children) it will collect the data and produce a new product that does not share anything with the original data and is completely forgotten by the producer, it will not be cached and will not be recalled. I don't see how that can't be considered generative |
It's made out of the concatenation of parts of the original data. That's not "not shar[ing] anything". My main problem with this is that if I see a signature like |
It doesn't because it neither reacts nor changes according to the data, nor does it get cached.
That's not what generate means though, generate literally means producing a product as a result, in this case its producing something from existing data, this isn't new in software, its fairly common for a new production of a value from existing known/runtime data to be called a generate function. If we take Javascript for example, generator functions almost literally refer to the same semantics, in that case it produces a new list because they're basically builtin enumerator returns in JS, but they rarely ever return anything but existing data in an enumerable format. |
As it stands and was said by Fayti1703 the current structure of ElementInfo has too much going on in it. A text node doesn't support names, children, or attributes and an element node doesn't intrinsically represent a value/content. (leaving attributes because they're more useful on the element) As a result it makes more sense to treat them distinctly and only modify their behaviors.
Proposal:
If there is anything anyone wishes to be added please comment.
The text was updated successfully, but these errors were encountered: