Book a Demo

Author Topic: DiagramLinks Collection returns in monotonic increasing ConnectorID order?  (Read 8114 times)

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
We have observed that the diagram links collection seems to be returned in monotonically increasing ConnectorID order.  Is this by design?  Can we rely on this for processing?

TIA,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
There is no explicit ordering applied. I would not recommend relying on it.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
There is no explicit ordering applied. I would not recommend relying on it.
Thanks, Eve (since that's your new signature)

Might continue to use with monitoring - since it considerably simplifies the processing we're doing.

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Might continue to use with monitoring - since it considerably simplifies the processing we're doing.

Really? that just sound like being lazy to me. :-X
How hard can it be to put the diagramlinks in a real collection and sort them (you can keep track of their original index if needed)? Especially since they seem to be ordered correctly most of the time, which means you will hardly notice the sorting in terms of performance.

Geert

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Might continue to use with monitoring - since it considerably simplifies the processing we're doing.

Really? that just sound like being lazy to me. :-X
How hard can it be to put the diagramlinks in a real collection and sort them (you can keep track of their original index if needed)? Especially since they seem to be ordered correctly most of the time, which means you will hardly notice the sorting in terms of performance.

Geert
"Not guilty, Your Honour!"

(Well not quite.)  The coding is being done by another of Santa's little helpers (work experience student) and so we have limited time.  Also for reasons, it's being written in VBScript - which, as you know, doesn't have a built-in sort.  So it's "roll your own" or call a library function.

Happy Friday everyone!
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Still no excuse. I just wrote a sort function myself and it took me all of 15 minutes or so?

Anyway, here's the code. First you need to put your diagramLinks in a dictionary with the connectorID as a key
Then use the function below to sort it. It uses the built-in ArrayList.Sort to do the heavy lifting.
This method only works if you have a list with unique key's

Code: [Select]
'returns a new dictionary that is sorted using it's key
function getSortedDictionary(dictionary)
dim sortedDictionary
set sortedDictionary = CreateObject("Scripting.Dictionary")
'get a list of key and sort the keys
dim sortedKeys
set sortedKeys = CreateObject("System.Collections.ArrayList")
dim key
for each key in dictionary.Keys
sortedKeys.Add key
next
'sort the keys
sortedKeys.Sort
'fill the dictionary with the values of the original dictionary using the sorted keys
for each key in sortedKeys
sortedDictionary.Add key, dictionary(key)
next
'return
set getSortedDictionary = sortedDictionary
end function

Geert

matthew.james

  • EA User
  • **
  • Posts: 155
  • Karma: +8/-3
  • Am I supposed to say something here ... ?
    • View Profile
Still no excuse. I just wrote a sort function myself and it took me all of 15 minutes or so?

When I was a boy we learned how sorting works, pros and cons of different algorithms (remember quicksort, mergesort, pigeon sort)
Now it's all just 'call that library ...'. Sigh !

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Still no excuse. I just wrote a sort function myself and it took me all of 15 minutes or so?

When I was a boy we learned how sorting works, pros and cons of different algorithms (remember quicksort, mergesort, pigeon sort)
Now it's all just 'call that library ...'. Sigh !
True, rolling your own is so much more fun, but not really something you get to apply in a professional setting.
In general the extra few seconds you might win by writing a more efficient algorithm don't weigh up against the cost of spending half a day of developer time (= money) to write it.
And not to forget the possible bugs introduced in by writing this new sorting algorithm.

That's one of the reasons I enjoy my on-the-side open source projects. I can spend as much of my own time writing the most beautiful/interesting/fun code as I want. :)

Geert

Geert

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Still no excuse. I just wrote a sort function myself and it took me all of 15 minutes or so?
Yes, and so could I, but my Helper couldn't write it in 15mins.

At a later date, we'll fix it.

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Still no excuse. I just wrote a sort function myself and it took me all of 15 minutes or so?
Yes, and so could I, but my Helper couldn't write it in 15mins.

At a later date, we'll fix it.

Paolo


Wait, what? First you call him Santa's little helper, then you call him YOUR helper. You aren't... you couldn't be... are you...?  :o
The Sparx Team
[email protected]

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: DiagramLinks Collection returns in monotonic increasing ConnectorID order?
« Reply #10 on: January 21, 2019, 09:57:59 am »
SemANTicA

q.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: DiagramLinks Collection returns in monotonic increasing ConnectorID order?
« Reply #11 on: January 21, 2019, 04:34:22 pm »
SemANTicA

q.
"You might well think that; I couldn't possibly say that"   - Francis Urquhart

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!