Jump to content
iyeager

Most ridiculous piece of code

Recommended Posts

Coding Without Comments

Alternately

"Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?"

Brian Kernighan, "The Elements of Programming Style", 2nd edition, chapter 2

Share this post


Link to post
Share on other sites

Yeah, I hate regex because they're so difficult to decipher, but love them because they're so bloody powerful.

Reminds me of perl code.

  • Like 1

Share this post


Link to post
Share on other sites

Yup. Any application I write after 6 months has elapsed :)

Make that 6 weeks for me.

Share this post


Link to post
Share on other sites
Know what this does?

post-2411-0-70152200-1351191387.jpg

Resolves host name? :D

Getting paid by the number of nodes - Priceless... (especially when you place your signature post-181-1170858537.png in every VI).

Things like that don't have a tangible effect on GOB counts, thankfully :)

Share this post


Link to post
Share on other sites
Yup. I love to see new devs scratch their head when they see that in my code...

I'd seen it before, but the file name was a giveaway :D

  • Like 2

Share this post


Link to post
Share on other sites

How about this gem?

post-181-0-69127900-1351189098.gif

In the same vein. Here's one I've seen before :frusty:

Edited by ShaunR

Share this post


Link to post
Share on other sites

Coding Without Comments

Alternately

"Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?"

Brian Kernighan, "The Elements of Programming Style", 2nd edition, chapter 2

I remember

Ritchie, Thompson, Plougher and Kernighan all talking about the merits of obscurity when trying to protect IP. It's an important lesson to bear in mind when considering how "easy" you want to your code for those who might follow...

Of course, we all DID know that Ritchie and Thompson left open some back doors, even though they denied it for many, many years.

Share this post


Link to post
Share on other sites

No way!

I've seen this plenty. To help me sleep at night, I pretend that the case structure once held functional value and through the course of because someone just forgot to refactor.

Share this post


Link to post
Share on other sites

No way!

Yup. I think originally they were using it to invert (instead of using the primitive) and during debugging/mods changed the booleans around so it was completely redundant.

  • Like 1

Share this post


Link to post
Share on other sites

I've seen this plenty. To help me sleep at night, I pretend that the case structure once held functional value and through the course of because someone just forgot to refactor.

To be honest, I think that's what happen with the one I shared too - I like to think, based on the whitespace around it, there was once some uber difficult logix going on there. At least, that's what I have to beleive.

Share this post


Link to post
Share on other sites

The original code is a unique opportunity to "do the right thing" and still wind up obfuscating your code. It is possible, and some think advisable, to actually add comments to your regex using (?#comment). This sounds good, and the added bonus is that it quadruples the size of your regex, diluting the information content. Of course since self-perceived cleverness scales directly (exponentially?) with the length of a regex you get to feel much better about yourself.

Some of the "best" code I have written is for working around the occassional (cough) bugs in LV, often the smallest ones lead to the most interesting workarounds. For example I once needed to know if the output terminal of a compound arithmetic node was inverted, a small oversight in the scripting properties. I'll describe the fix (which only gets better each time I look at it):

Copy the Compound Aritmetic Node.

Create a New VI

Paste the Node into the BD

Shrink to one terminal

Check for inverted input (at least you can do that), remove invert if needed

Change mode to add

Wire constant 1 to input

Create indicator

Run the new VI

Check output, if it == -1 then the output is inverted

Resume scripting..

The best part, I'll wager most people either do not realize you can invert the output and the few that do, never do.

Share this post


Link to post
Share on other sites

> ...I once needed to know if the output terminal of a compound arithmetic node was inverted, a small oversight in the scripting properties...

For those that are curious, this scripting deficiency has been reported to R&D as CAR 197239, and is slated to be fixed in the next LabVIEW release.

Share this post


Link to post
Share on other sites

For those that are curious, this scripting deficiency has been reported to R&D as CAR 197239, and is slated to be fixed in the next LabVIEW release.

I was probably the only person keeping score on that one at home, but a little birdie told me that this was fixed as an afterthought to a second CAR which is probably much more useful to many of us. I do not want to jinx anything though.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.