LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

What are your go-to tools for understanding existing code?


@billko wrote:

@Dave_St wrote:

Ah yes, block diagram cleanup can bring huge gains! Thanks for the reminder.

 

But not auto block diagram cleanup (in my experience). 


If the cleanup tool improves the look of your block diagram, you need to seriously rethink your block diagram design.  😄


This takes the total wire length / 100, then adds the number of bends.  Runs the cleanup tool, then calculates again.  Ratio of the two numbers tells how bad it is.

Not super accurate, but it's something.

"If you weren't supposed to push it, it wouldn't be a button."
Message 11 of 18
(594 Views)

@paul_cardinale wrote:

...


This takes the total wire length / 100, then adds the number of bends.  Runs the cleanup tool, then calculates again.  Ratio of the two numbers tells how bad it is.

Not super accurate, but it's something.



Why is it password-protected? Do I dare to run a VI that I don't know what it does? Where is the VI from?

 

But an interesting measurement anyway.

Certified LabVIEW Architect
0 Kudos
Message 12 of 18
(532 Views)

D'oh!

I meant to remove PW protection.

Here.

"If you weren't supposed to push it, it wouldn't be a button."
Message 13 of 18
(494 Views)

Bookmarks can be a useful tool especially for larger projects. The Bookmark Manager makes it easy to jump to related items quickly.

Use Bookmarks to document your progress and to highlight areas that will require more investigation. 

 

Once you get used to them you will find many use cases. 

 

"Comments are a lie waiting to be told.", Author Unknown

--------------------------------------------------------------------------------------------------------------------------
Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
question. Give "Kudos" to replies that help.
--------------------------------------------------------------------------------------------------------------------------
Message 14 of 18
(434 Views)

If the code is complicated and hard to understand, I will often look for common pieces of code (no matter how small), create sub-VIs out of them and replace the code with sub-VIs. This gives them some sort of structure, where I can begin to locate regular operations as opposed to clumps of messy LV code. Just having some pieces of recognisable common code with icons makes reading a lot of code much easier. When the difficulty of understanding code increases with the square or the cube of the number of nodes, reducing even a few little pieces of code like this can help flatten the curve into getting familiar with what's going on.

 

Once the code is kind of readable, I start following the actual code progress mentally, before even starting to run the code. Once I feel like I've understood what's going on, I'll often actually revert to the original code for testing, and when I see how it behaves, re-introduce the sub-VIs one by one making sure they work as expected.

 

Of course this depends greatly on the scope of the code being investigated.

Message 15 of 18
(392 Views)

@crossrulz wrote:

The only thing worse than no documentation is wrong documentation.

 

When I inherit "ancient" code, I refactor to understand it.  Breaking things into subVIs, improving that portion (subVIs help a lot with regression testing).  Of course, make sure this code is locked away in a Source Code Control before doing anything to it.


That's a great way to gain understanding of old code. Of course while adding comments to help remember what you've deciphered so far. Just changing names of controls and wires can be quite helpful, i've had much code with Data this and Value that instead of useful naming.

G# - Award winning reference based OOP for LV, for free! ADDQ VIPM Now on GitHub
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Certified-LabVIEW-Developer
0 Kudos
Message 16 of 18
(357 Views)

I don't think cleanup tool helped me even once, usually it makes it worse. I do use it for forum examples tho 😄

0 Kudos
Message 17 of 18
(347 Views)

@paul_cardinale wrote:😄

This takes the total wire length / 100, then adds the number of bends.  Runs the cleanup tool, then calculates again.  Ratio of the two numbers tells how bad it is.

Not super accurate, but it's something.


Oof, my first large VI has a score of 1000+ ranked as sewage. I feel attacked.

 

Then again, i checked the VI and it's now totally **bleep**ed because of the cleanup tool... maybe should have warned about that

Message 18 of 18
(332 Views)