(c) 2005 by Lousy Coder

In my line of work, I sometimes have to help people who have inherited other people’s Flash, Authorware, or Javascript. Often this code is messy, uncommented, and done in the most tedious and ham-handed fashion. So fine, most amateur code slingers aren’t going to find the most elegant or effective solution to a coding problem.

What gets me is the inevitable comments at the top of the file, which read

© 2005 by Someguy W. Doesnthaveaclue.

swnoclue@hotmail.com

First, the code isn’t worth copyrighting – it’s crap. Second, if you did in your line of work you don’t own the copyright – the U does. If grant money supported the project, it can’t be copyrighted at all. Third, your code is hackneyed, boring, predictable, and replicable by anyone who read the same book you stole it from. Fourth, it’s not worth copyrighting – it’s crap. I know I said that already, but it bears repeating.

Copyrighting bad code is like copyrighting office memos or e-mails. Do you really think you’ve created “intellectual property” with salable value? Guess what. You haven’t. And even if you did, you don’t own it. You were paid to write it, and it belongs to whoever paid for it.

10 Postcount = Number of OP’s Posts
20 If Postcount>2000, Then Print “I agree!!!”
30 If Postcount<2000, Then Print “This thread is stupid!!!”
40 END

© 2005 Fluiddruid, fluiddruid@dontspamme.com

This thread is stupid!!!

I agree!!!

(to Lawyers)
Seize him! :mad:

Does this mean that when cricetus has posted 224 more times (as of the time of this post, all of the “This thread is stupid!!!” posts have to be changed to “I agree!!!” posts? Veb and Giraffe aren’t going to like that extra work.

Don’t ask me. I’m a lousy coder.

Cripes, you still use basic?

Try this:



var postcount = thread_array.length
if ( n > 2000 ) {
     thread_array.push( "I aree! ");
} else {
     thread_array.push( "This thread is stupid!" );
}


It is, after all, the 21st Century.

Cripes, you still use basic?

Try this:



var postcount = thread_array.length
if ( n > 2000 ) {
     thread_array.push( "I agree! ");
} else {
     thread_array.push( "This thread is stupid!" );
}


It is, after all, the 21st Century.

I agree!!!

No worries, just write some code to do the changes for you. Make sure you copyright it and then sell it to the other mods for a fortune!

Enjoy,
Steven

Undefined variable: n
:stuck_out_tongue:

You got comments? Luxury.

Try decoding 5,000 lines of undocumented spaghetti code, complete with useless and similar variable names like i, ii, il, ili, iil, and iliil, with functions and subroutines 300-lines long, all in one honkin’ big file…

Dude, that code wasn’t meant to be decoded. What are you trying to do, wreck some guy’s job security?

So do it the modern way:


printf( "%s
", ( postCount > 2000 ) ? "I agree!" : "This thread is stupid!" );

Regarding the OP, what you’re dealing with is bad habit. These people were told to comment their files up, down, left, and right, but nobody mentioned to them that you should only put in relevent comments. So, they dump spam in in lieu of anything useful.

Though, those © comments are useful! You know who wrote that piece of crappy code! You can strap on the chainsaw, hunt them down and exact justice upon them for the apostacy they have committed against humanity with their ill-formed “code” (translation: blight upon civilization).

Yes, I’ve debugged other people’s “code” before. OH GOD NO. I’m having flashbacks… I’m not going to sleep tonight…

Hey, I’d gladly help support his job security if he’d actually stuck around and fixed his code…

In the small amount of coding I do at work, we are required to identify ourselves as the author of every piece of code we write. I believe this is primarily so that better coders can come by to tell you they read your code, point, laugh heartily for five minutes, start to explain how to do it right, laugh some more, then wander off. (OK that only happened to me once. Yes, I deserved it.)

This is good practice with which I heartily agree (for the reasons you noted :wink: )*.

However, the OP is blasting idiots that think their unworkable glurge should be copyrighted (when it should usually be expunged).

  • (Of course, in an intelligent universe, code is maintained in a separate system with benchmarks and forward- and backward-applied revision IDs so that one need only indicate your name at a revision number at a single point to have all the modified code identified to future generations.)

I can’t believe you added a copyright to this piece of code-glurge.

First off, line #10 is using a global variable – evil! The variable should clearly be added to a class as a private member. Then add a get accessor function to hide the implementation details. Furthermore, don’t use the class directly, derive it from an interface and use instances of that interface, in case you need to add other implementations. Finally, consider applying the adapter pattern so that you can query the postcount from any number of data-sources: database, XML, memory-mapped file, etc. And consider applying the proxy and chain-of-command patterns, so that you adapters can be chained together and query the postcount from various sources dynamically.

Now let’s look at the travesties called lines #20 and #30. You used a hard-coded value? What were you thinking? Pull it out into a #define (at least), but consider moving it to an external data-source (see comments above). This will allow the code to be completely extensible for any post count thresholds. Keep in mind, that the thresholds for #20 and #30 should be unique as well. Never assume that you can print to stdio. Abstract the print destination by opening a dynamic file-stream. We can use this to output to any number of devices: screen, printer, braille display – anything. Also, what is up with the hard-coded English strings? This can’t be localized. Pull the strings out into a properties file indexed by language, country, and region. It is the only way we can deploy this code in Latin America.

Finally, what is up with the obnoxious code-bloat that is called line #40? END is implicit. Why increase your code size by 25%? We will want to deploy this code on a multitude of platforms including cell-phones, pixie sticks, and the Internet-enabled vibrator (a.k.a. iBrator).

Seriously, I know someone that needs to enroll in GW-Basic for Distributed, Extensible, Internationalizable Web Applications for Dumbos.

:slight_smile: