I want to rename the ParseUnit GetNode method to simply Node, and NodeTypes GetNodeType to NodeType
Message ParseUnit:GetNode(1):NodeText view-as alert-box.
would become
Message ParseUnit:Node(1):NodeText view-as alert-box.
also, I would like to add Item as a synonym for Node / NodeType
Message ParseUnit:Item(1):NodeText view-as alert-box. Message Proparse:NodeType:Item(1):TypeName view-as alert-box.
any objections to this ?
I want to differentiate between methods that return a value GetNodeText(nodenum) and an object Node(NodeNum)
Re: Want to change GetNode to Node
That sounds good to me. A couple more trivial suggestions (I'm not fussy about these)...
Use
text
rather thannodeText
Perhaps we should follow suite with other languages. Use UpperCase when referencing a Class, and lowerCase when referencing anything else (object instance, variable, property, method). You will find more and more people using a mix of OE+C#, or OE+Java, and this will be easier on their eyes. :)
so, this would be message
so, this would be
or
No - it's just the first
No - it's just the first letter that is traditionally uppercase for a class name, like ClassName.cls.
Coming from Java (or C#), when I glance at this:
I get confused because ParseUnit suggests to me that you are refering to the class, which would mean to me that node() would have to be a static class method.
I did want to do that
I did want to do that originally, but progress complains with a syntax error
does not compile. Neither does "Col"
So, once text was not available, it didn't make sense to have Node:Index, Node:Line, but Node:NodeText and Node:NodeCol so I settled on Node:NodeLine etc for consistency
Sheesh. Stupid reserved
Sheesh. Stupid reserved keywords!
It seems a shame to make all of the property names so long just because a few of the names we want are reserved.
node:nodeLine
is an awful lot of clutter. It's as bad as using 'getters' for everything! Likenode:getLine()
. Properties in ABL are a great language feature, and using 'node' in every property name almost defeats the purpose.How about non-keyword names, like '
txt
' and 'colmn
'? We don't really have to remember those goofy names, because we have code-completion in OE Architect.so, the properties of class
so, the properties of class node become
nodetext == txt
nodecol == colm
nodeindex == idx
nodeline == line
nodefilenum == filenum
nodetypenum == typenum
NodeType == Type (class NodeType)
I *dont* like colm, but can't think of a better name ...
"colm" sure is an ugly
"colm" sure is an ugly name.
Generally I like to avoid abbreviations, so I would consider (apart from casing):
colm = columnposition
line = linenumber
filenum = fileindex
typenum = typenumber (or is it actually typeindex)
NumNodes = Count ?
just to split some hairs... "ParseUnit:NumNodes" reminds me of "Nodes:Length" (when in Java) or "Nodes:Count" in some other languages.
a collection class usually has a Length or Count property.
ParseUnit is not really a collection of Nodes, but close enough, and since you also brought up Item(n) I figured it might make sense to also have a Count property.
it would be a trivial task
it would be a trivial task to add a nodes collection to the parseunit (it would actually be a lot "neater" in design)
so instead of
we would have
Would that be better ?
Re: parseUnit:Nodes
Wouldn't it make the implementation more clumsy? Aren't there lazy-load methods that operate on the blob that would have to be shared between ParseUnit and a new collection class, say, '
NodeList
'?It just sounds like extra work to me. I don't know the state of Collection classes in ABL 10.1C. I suppose it could work and be sensible if NodeList were a subclass of a standard Collection class, and NodeList was free to implement all its methods as lazy-load methods operating on the blob.
I'd find this sort of thing easy to understand and use:
Operating on the list of nodes is not really a normal way of doing things anyway. Getting parseUnit:topNode and then walking down through the syntax tree is common. Getting a list of nodes with something like parseUnit:queryType("DEFINE") is very common in Prolint.
you could do that, and also
you could do that, and also do
there is nothing new in collection classes for 10.1C. Unfortunately.
I would use the "introduce
I would use the "introduce variable" refactoring on that particular piece of code.
I don't know about ABL, but in most other languages there is some overhead in the use of an accessor method. (nodeList is a PROPERTY, right?) I would introduce a variable even if I was only using the accessor a few times. In a tight loop like this, reducing function calls is almost always best practice.
(Even if ABL does something clever so there's no overhead in a default GET, that doesn't mean that the author of the GET method won't change its implementation the future.)
That raises a question about the implementation of Schema.cls. Is there a difference in performance between using a PROPERTY and using a public var? A PROPERTY (with accessors) is always better practice, but Schema.cls is not really intended to be a 'public' part of the API, and performance trumps best practice.
I don't know about ABL, but
Absolutely, that's what I would do. However, I was just noting that it could be done this way.
the following code:
gives the following results:
accessing a:foo 809ms
accessing a:bar 800ms
so a property is actually faster :)
Kudos to the OE compiler
Kudos to the OE compiler team!
I have to confess I was
I have to confess I was surprised :) Have you run the code on your machine to check my results ?
I got similar results.
I got similar results.
yay!
yay!