Code Smells In LABVIEW–Part 4

Part 4 of my code smells series (1: Spaghetti code, 2: Sequences, 3: Cluster Problems) is about small things I don’t like to see in code.

About stuff that I can’t understand.

I hate magic numbers. (Wikipedia) If you are comparing something against a constant, give that constant a name. If you are using it more than once (well, twice, I’m feeling generous), consider moving it to some sort of subvi, typedef or whatever suits your needs. The nature of the problems usually solved by LV includes a lot of physics and hardware constants, which I’ll excuse some things (please do not redefine gravity!), but you get the point.

Don’t use variable names like process, data, loop variable, counter, change,..

Be careful with the deactivation structure. I often include some sort of debug/log modus with that. I use it to switch between test data and production data, and those are perfectly good reasons to use it. It’s a great thing to use for debugging, for development.
If I see huge parts deactivated in production code, I’m going to ask questions. Why is it here? Why did it stay? Is it a test? Is it something unfinished?
At least label it and explain that to me.

Advertisements

2 comments

  1. […] if you have performance issues, we should have another talk Next part: Stuff I don’t understand.. Share this:TwitterFacebookLike this:LikeBe the first to like […]

  2. […] code, sequences that violate data flow, or clusters that replace decent data structures and stuff that nobody understands. Duplicate code. Lack of comments. Useless, verbose comments (“Increase i by one”). […]

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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: