From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
Dragis

BLOCK DIAGRAM CLEANUP SHOULD REORDER BUNDLE/UNBUNDLE ELEMENTS

Status: New

the cleanup tool is useful and getting more useful each release. however, i still find myself having to cleanup section of code doing bundling and unbundling by hand because it requires manually reordering the names within the nodes. even worse, i sometimes reorder things and then run the cleanup tool again and it decides to move things around such that another reordering is necessary (ick!). let's just give the cleanup tool the freedom to reorder the elements itself. for unbundles it's always safe.  with bundles care must only be taken if a value later in the bundle overrides a previous element in which case those few elements would have to maintain their ordering (which is a fairly low use-case i would guess).  

 

 

cluster-cleanup.png
 

 

6 Comments
altenbach
Knight of NI

I don't always want to unbundle or bundle in elements in a certain order. The order is typically determined by the way it best fits the rest of the code, eliminating wire crossings.

 

Also, remember that we can bundle the same element more than once. If we bundle the same element multiple times, the lowest one wins.

 

Such cleanup operation should probably also consolidate multiple terminals for the same element and use wire branches instead. Personally, I think it is too dangerous to have such changes done automatically. Your upper figure is better self-documenting. It is immediately clear that values are shuffled around between cluster elements. The lower image might give a false impression on first glance.

 

 

Intaris
Proven Zealot

Something about this makes my brain scream "NO".

 

I've had bad experiences in the past with automatic re-assignment of cluster terminals (in the background and without telling anyone)  that I never ever want LV "interpreting" my terminaly again.

RavensFan
Knight of NI
I agree with Altenbach and Intaris on the No.  It is too risky it will change the functioning of the code.  This use case would be so infrequent and needs to be so carefully monitored that if you need to do this, you should just take the time to do it yourself and think it through.  If your problem is so large that you really need the automated help of the code cleanup tool for this particular use case, then you probably have a serious architecture problem you should be resolving.
Dragis
Active Participant

wow, i must be missing something here. the idea that i have proposed WILL NOT change the functionality of the code. it will also not change any cluster types on the diagram. it is to simply allow the block diagram tool to change the order (in a purely cosmetic way) of the elements of a bundle/unbundle node (not the cluster itself) so i has more freedom to do its work. 

 

perhaps i'm the only person that's ever written a diagram and when all was said and done i had a lot of wire crossings between the code and the unbundle/bundle nodes; i'm certain this isn't the case. at this point, i have to manually disconnect the wires, reorder the elements in the nodes to be the 'cleaner' way, and then reconnect the wires again. as far as i can tell, this is a completely harmless thing to do and i'm sure i've had many, many people do this same process after code reviews to clean things up.

 

if my example 'cleanup' above actually changed the functionality of the diagram, that was not intended. i just looked at it again and i can't find a functional change; the only change is that the code is cleaner with less wire crossings. 

altenbach
Knight of NI

In a nutshell:

 

"should the cleanup tool be allowed to cosmetically reorder the bundle/unbundle terminals on order to lower the number of wire crossings?"

 

As I said, I actually do that manual in certain cases. The idea is not bad. 

 

Should it be done automatically? Maybe not. There are so many more degrees of freedom because there is a huge number of combinations without wire crossings, for example in your case it could equally well reorder the unbundle node (or shuffle the unbundle node an reorder the bundle node accordingly). Only I know which one I want.

 

In non-ideal code (and the world is full of these!) There is a potential for actual data change in the cases where there are more than one terminal of the same name (if the element names are unique but we select the bundle terminal twice with different inputs).

 

Don't forget the bundle/unbundle terminals of the "in place element" structure. Would you also want to be able to have a case where the terminal order on the right is different to the one on the left? That would be confusing.

 

 

I never use cleanup on my own code, so having this option would not make a difference for me. I only cleanup code written by others as a first step to make sense out of it all. 😉

 

Maybe a better (manual!) option would be a right-click entry "reorder terminals" (would look similar to "reorder cases" in a case structure) or some other mechanism (e.g. hold down ctrl and click two terminals in sequence, similar to the swap connectors idea.

Message Edited by altenbach on 04-16-2010 10:00 AM
Dragis
Active Participant

i think you are right on altenbach ...


altenbach wrote: 
I never use cleanup on my own code, so having this option would not make a difference for me. I only cleanup code written by others as a first step to make sense out of it all. :smileywink: 

 


i just don't agree with your conclustion 🙂 

 

in general, i run the cleanup tool on existing code (that i probably didn't own) to make the diagram easier to understand. in those situations, i want to give the tool as much freedom to clean up the diagram as it can so the diagram will be easiest to read. it seems useful to let the tool automatically reorder the elements if it will make the diagram contain fewer wire crossings.

  


altenbach wrote:
Should it be done automatically? Maybe not. There are so many more degrees of freedom because there is a huge number of combinations without wire crossings, for example in your case it could equally well reorder the unbundle node (or shuffle the unbundle node an reorder the bundle node accordingly). Only I know which one I want. 
In non-ideal code (and the world is full of these!) There is a potential for actual data change in the cases where there are more than one terminal of the same name (if the element names are unique but we select the bundle terminal twice with different inputs). 

 

 

i agree that there are many degrees of freedom once you allow the tool to treat each element separately, that's part of why i like the idea. the tool can iterate through many possible orderings in the blink of an eye.

 

and as far as the order dependencies, the tool would certainly have to ensure no functional changes are made. that's already dealt with for other situations i'm sure. 

  


altenbach wrote: 
Maybe a better (manual!) option would be a right-click entry "reorder terminals" (would look similar to "reorder cases" in a case structure) or some other mechanism (e.g. hold down ctrl and click two terminals in sequence, similar to the swap connectors idea. 

 

 

i was actually planning on suggesting that feature as well, i just hadn't had time to search to see if it already existed. i would certainly use the feature if it existed as i'm much too picky in most cases to trust the cleanup tool on new code.