Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Paolo F Cantoni on June 15, 2016, 02:33:59 pm

Title: Comments in Shapescripts
Post by: Paolo F Cantoni on June 15, 2016, 02:33:59 pm
Do comments in shapescripts affect the execution speed or are they discarded on the way in?

We are interested in making our shapescripts more expressive ina narrative sense, but if that makes them slower, then we won't.  If there's only a one-time hit on injestion then that's OK.

Support request submitted,
Paolo
Title: Re: Comments in Shapescripts
Post by: Geert Bellekens on June 15, 2016, 04:07:00 pm
Paolo,

I would be very surprised if comments affected the execution in a less then trivial way.

But better safe then sorry I guess  :-\

Geert
Title: Re: Comments in Shapescripts
Post by: Paolo F Cantoni on June 15, 2016, 05:17:21 pm
So would I Geert; but as you say, before plastering the scripts with a LOT of commentary, better find out.

They currently have some commentary, but we'd loke to "beef it up" - especially in the area of identifying common code (since you can't cross call)

Paolo
Title: Re: Comments in Shapescripts
Post by: Geert Bellekens on June 15, 2016, 05:21:45 pm
BTW, I'm working on a script to export the shapescripts to textfiles so you can put them into a version control system.
I've done the same for my scripts a while ago in order to get "some" level of control on what is happening with them.
It also allows for easy searching if I need to find something in the scripts.

I'll let you know when it's finished.

Geert
Title: Re: Comments in Shapescripts
Post by: Paolo F Cantoni on June 15, 2016, 05:41:36 pm
BTW, I'm working on a script to export the shapescripts to textfiles so you can put them into a version control system.
I've done the same for my scripts a while ago in order to get "some" level of control on what is happening with them.
It also allows for easy searching if I need to find something in the scripts.

I'll let you know when it's finished.

Geert
That's good Geert, but what I REALLY want is to go the other way...  ;)
For each <shapescript text file> populate the MDG file in the appropriate place.  That way, I can generate the script text files from a generator and then get them inserted into the MDG without the "faffing about" we need to do at present.

We already have a large amount of common code and we'd like to increase it.

I got RSI (Repetitive Strain Injury) of the elbow updating 50+ scripts the other weekend.

Paolo
Title: Re: Comments in Shapescripts
Post by: Geert Bellekens on June 15, 2016, 06:12:13 pm
One of the things on my TODO list as well :)

I'm developing scripts, profiles and shapescripts and putting them into MDG files for a couple of different clients, and I'm trying to get a grip on it all.

So a tool that would allow me to push a button and regenerate my MDG, without having to point and click on 70 different things (without missing one) would be a big help for me too.

Geert
Title: Re: Comments in Shapescripts
Post by: qwerty on June 15, 2016, 08:23:45 pm
I think we need a confirmation from Sparx. If I were to design this, I would compile the script upon saving and use the compiled code. But I seem to remember that until a not so long ago time it was possible to save scripts with syntax errors (until I complained about that). That's a good indication that it was not compiled then, but most likely interpreted at runtime.

q.
Title: Re: Comments in Shapescripts
Post by: Geert Bellekens on June 15, 2016, 08:37:41 pm
I think the shapescripts are interpreted and not compiled, but I don't know for sure.

Geert
Title: Re: Comments in Shapescripts
Post by: Paolo F Cantoni on June 16, 2016, 09:49:58 am
I think the shapescripts are interpreted and not compiled, but I don't know for sure.

Geert
Well, even if they were interpreted, they should be interpreted on a minified version minus comments and other stuff that would increase processing time.  Perhaps even on an intermediate form.

I'll await the Sparxians' response and let you know.

Paolo
Title: Re: Comments in Shapescripts
Post by: Paolo F Cantoni on June 16, 2016, 05:32:07 pm
I've received a reply from the Sparxians:

Shape Scripts are interpreted, not compiled.  Having comments in your shape script should make almost no difference to the processing time required by EA, but still could in theory make a very, very small difference.

We certainly haven't observed any noticeable difference before.

This is heartening, and I'm trying to get some more clarifications which I'll pass on.

When I was composing the original question, I had in my mind something like:
Given a total character count in a shapescript of 2500 characters in 100 lines,  Suppose 10% of the characters on 15% of the lines were within comments.   Would that be the kind of situation you (the reader) experience?  If not, what is your exemplar?

I think if we increased the level of commentary (for a variety of purposes), that same script might go up to about 3000 characters on 120 lines with the comment ratio moving to, perhaps, 15% of characters on 20% of the lines.  It might be interesting to see if there was a difference.

Thoughts?
Paolo
Title: Re: Comments in Shapescripts
Post by: qwerty on June 16, 2016, 06:39:08 pm
So my suspicion was right... I for myself hardly write any comment in code (it should go to the model). Instead I try to code in a readable fashion.

Probably the comments themselves will really not affect processing time too much. But, honestly, interpreting during diagramming is poor design. Even if they were to use Java Script it would be compiled to some byte code. Probably now you know why large diagrams take ages to load.

q.
Title: Re: Comments in Shapescripts
Post by: Geert Bellekens on June 18, 2016, 04:39:47 pm
BTW, I'm working on a script to export the shapescripts to textfiles so you can put them into a version control system.
I've done the same for my scripts a while ago in order to get "some" level of control on what is happening with them.
It also allows for easy searching if I need to find something in the scripts.

I'll let you know when it's finished.

Geert
It's finished  ;D

So now there a new repository on Github with all(most all) of my shapescripts:
https://github.com/GeertBellekens/Enterprise-Architect-Shapescript-Library (https://github.com/GeertBellekens/Enterprise-Architect-Shapescript-Library)

The script to export them can be found here, but it works in conjunction with the other wrappers in the library:
https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/blob/master/Framework/Tools/Script%20Management/ExportAllShapeScripts.vbs (https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/blob/master/Framework/Tools/Script%20Management/ExportAllShapeScripts.vbs)

If you want to know how to use the vbscript library see: https://bellekens.com/2015/12/27/how-to-use-the-enterprise-architect-vbscript-library/ (https://bellekens.com/2015/12/27/how-to-use-the-enterprise-architect-vbscript-library/)

It's still a first rough version that needs some refactoring, but it got the job done :-\.

Geert
Title: Re: Comments in Shapescripts
Post by: Geert Bellekens on June 20, 2016, 06:59:52 pm
Some of the refactoring is now done, and I've written a small article explaining things:
Presenting the new open source Enterprise Architect Shapescript Library (https://bellekens.com/2016/06/20/presenting-the-new-open-source-enterprise-architect-shapescript-library/)

Geert
Title: Re: Comments in Shapescripts
Post by: Geert Bellekens on June 30, 2016, 11:29:14 pm
I've created a new script to extract the shapescripts from MDG files and I've extracted and uploaded all of them to the github library.
Which now contains over 1000 shapescripts with more then 30.000 lines of code. :o

Geert
Title: Re: Comments in Shapescripts
Post by: Paolo F Cantoni on July 01, 2016, 09:32:07 am
I've created a new script to extract the shapescripts from MDG files and I've extracted and uploaded all of them to the github library.
Which now contains over 1000 shapescripts with more then 30.000 lines of code. :o

Geert
Hi Geert,
Unfortunately I don't have time to check it out right now - other issues in play.  But can you confirm that you can now reverse engineer an MDG file (not a profile in a repository) and generate text files - to be version controlled.

Paolo
Title: Re: Comments in Shapescripts
Post by: Geert Bellekens on July 01, 2016, 01:17:07 pm
I've created a new script to extract the shapescripts from MDG files and I've extracted and uploaded all of them to the github library.
Which now contains over 1000 shapescripts with more then 30.000 lines of code. :o

Geert
Hi Geert,
Unfortunately I don't have time to check it out right now - other issues in play.  But can you confirm that you can now reverse engineer an MDG file (not a profile in a repository) and generate text files - to be version controlled.

Paolo
Hi Paolo,

Yes I can, but (currently) I only get the shapesripts out.
The script is uploaded into github: https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/blob/master/Framework/Tools/Script%20Management/ExtractShapescriptsFromMDG.vbs (https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/blob/master/Framework/Tools/Script%20Management/ExtractShapescriptsFromMDG.vbs)

Geert
Title: Re: Comments in Shapescripts
Post by: Paolo F Cantoni on July 01, 2016, 04:32:13 pm
Hi Paolo,

Yes I can, but (currently) I only get the shapesripts out.
The script is uploaded into github: https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/blob/master/Framework/Tools/Script%20Management/ExtractShapescriptsFromMDG.vbs (https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/blob/master/Framework/Tools/Script%20Management/ExtractShapescriptsFromMDG.vbs)

Geert
Had a  quick look and it's neat!  I can see how it can form the basis of a round-trip mechanism for shape scripts.

I want to maintain shapescripts outside of profiles so that I can manage common script fragments across all scripts.  For example, if a user decides to place a note in a relationship, we think that's important enough to place a decoration on the relationship to that effect.  I want all relationships shapescript to have the same script fragment to do that.  I can maintain that globally outside of a profile and just reverse engineer the updated scripts into the MDG using the opposite to this code.

Paolo
Title: Re: Comments in Shapescripts
Post by: Geert Bellekens on July 01, 2016, 05:32:11 pm
Yes, you could do that, but wouldn't it be easier to do that based on the profile in EA?

The first script I wrote extracts the shapescripts from the _image attribute on the stereotype.

Geert
Title: Re: Comments in Shapescripts
Post by: Paolo F Cantoni on July 01, 2016, 06:36:02 pm
Yes, you could do that, but wouldn't it be easier to do that based on the profile in EA?

The first script I wrote extracts the shapescripts from the _image attribute on the stereotype.

Geert
Yes, it would except I have no profile as yet...  We've been maintaining our MDG file WITHOUT any direct repository support (in the form of a profile) for over a year.  The MDG is currently nearly 1Mb and will shortly go larger.

I might use the reverse engineerer to possible create such a profile.  It's so fast to change the MDG (now that we know exactly what we're doing) that we couldn't justify the manual expense of setting up a profile from scratch.

Paolo
Title: Re: Comments in Shapescripts
Post by: Geert Bellekens on July 01, 2016, 06:54:52 pm
Yes, it would except I have no profile as yet...  We've been maintaining our MDG file WITHOUT any direct repository support (in the form of a profile) for over a year.
Wow, that's really hardcore  :o

Geert
Title: Re: Comments in Shapescripts
Post by: Paolo F Cantoni on July 02, 2016, 11:06:40 am
Yes, it would except I have no profile as yet...  We've been maintaining our MDG file WITHOUT any direct repository support (in the form of a profile) for over a year.
Wow, that's really hardcore  :o

Geert
Yes, I agree!  8)  We DID start slowly...   A small change here, another there...  But as we got to understand how it works, we became more and more adept and confident.  Now, it's almost second nature...

For example, the recent COMPLETE revamp of the MDG to completely separate it from the previous Sparx ArchiMate MDG was done using only Notepad++ and 1 single stereotype profile (used to manually convert shapescripts and icons - which needed updating (those shapescript fragments I mentioned)).

Paolo