Code Smells In LABVIEW–Part 3

This is part of a series on code smells in LabVIEW. #1 is about huge, messy piles of spaghetti, #2 is about not thinking dataflow, and this part is about thinking that everything is a cluster.

About creating clusters for the sake of cleaning up. About confusing clusters with a decent data structure.

It’s some weird sort of intermediate level programmer error, or something done when your code is ugly  and you don’t want those wires and everything and you are tired and this is just messy..

Clusters are easily created.

Clusters are easily passed through loops, they don’t up much space in the higher levels of subvis, and if a very low-level logic part has some ugly cluster separation in it, nobody sees.

Clusters hide that you haven’t put much thought in your data structures.

Use them. For god’s sake, they make your block diagrams readable. If you really want to use one “data item” per state (queued state machine!), do so – but put some thoughts in them. Use variants.

Use typedefs.
(Well, you probably need to learn the lesson of having to change one item in an element and not having used a typedef in a program with hundreds of subvis only once.)

Group items logically

If you pass a position, cluster x and y. If you pass image processing data, group parameters..

Torvalds once said:

I will, in fact, claim that the difference between a bad programmer and a good one is whether he considers his code or his data structures more important. Bad programmers worry about the code. Good programmers worry about data structures and their relationships.

I’m not somebody who likes to quote without context (which is here), but if you’ve figured out your data, you’re pretty far ahead in the game.

Oh, and if you still want to get one huge cluster and think that’s good programming style (it can be) – look into OOP. LabVIEW does support object oriented programming, and it’s not even bad. (Said by someone who refused to even look at it until someone showed off a very nice library.)

And if you have performance issues, we should have another talk 😉
Next part: Stuff I don’t understand..


One comment

  1. […] part in the series: Using clusters and not thinking about data structures. Share this:TwitterFacebookLike this:LikeBe the first to like […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: