# (c) 2005 by Lousy Coder

**URL:** <https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722>\
**Category:** The BBQ Pit\
**Created:** [September 21, 2005, 3:48pm UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722 "2005-09-21T15:48:41Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![tnetennba](https://avatars.discourse-cdn.com/v4/letter/t/7993a0/32.png) [@tnetennba](https://boards.straightdope.com/u/tnetennba)\
**Post date:** [September 21, 2005, 3:48pm UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/1 "2005-09-21T15:48:41Z")

</div>

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](mailto: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.

---

<div class="post-metadata">

**Author:** ![fluiddruid](https://avatars.discourse-cdn.com/v4/letter/f/c2a13f/32.png) [@fluiddruid](https://boards.straightdope.com/u/fluiddruid)\
**Post date:** [September 21, 2005, 7:58pm UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/2 "2005-09-21T19:58:36Z")

</div>

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](mailto:fluiddruid@dontspamme.com)

---

<div class="post-metadata">

**Author:** ![Stringer](https://avatars.discourse-cdn.com/v4/letter/s/eb8c5e/32.png) [@Stringer](https://boards.straightdope.com/u/Stringer)\
**Post date:** [September 21, 2005, 8:01pm UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/3 "2005-09-21T20:01:10Z")

</div>

This thread is stupid!!!

---

<div class="post-metadata">

**Author:** ![Scarlett67](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/scarlett67/32/7387_2.png) [@Scarlett67](https://boards.straightdope.com/u/Scarlett67)\
**Post date:** [September 21, 2005, 8:05pm UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/4 "2005-09-21T20:05:48Z")

</div>

I agree!!!

---

<div class="post-metadata">

**Author:** ![CynicalGabe](https://avatars.discourse-cdn.com/v4/letter/c/3e96dc/32.png) [@CynicalGabe](https://boards.straightdope.com/u/CynicalGabe)\
**Post date:** [September 21, 2005, 8:09pm UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/5 "2005-09-21T20:09:38Z")

</div>

> [@micahjn](#):
>
> This thread is stupid!!!

(to Lawyers)  
Seize him! :mad:

---

<div class="post-metadata">

**Author:** ![tomndebb](https://avatars.discourse-cdn.com/v4/letter/t/b9e5f3/32.png) [@tomndebb](https://boards.straightdope.com/u/tomndebb)\
**Post date:** [September 21, 2005, 8:31pm UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/6 "2005-09-21T20:31:43Z")

</div>

> [@fluiddruid](#):
>
> 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
> 
> (C) 2005 Fluiddruid, [fluiddruid@dontspamme.com](mailto:fluiddruid@dontspamme.com)

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.

---

<div class="post-metadata">

**Author:** ![fluiddruid](https://avatars.discourse-cdn.com/v4/letter/f/c2a13f/32.png) [@fluiddruid](https://boards.straightdope.com/u/fluiddruid)\
**Post date:** [September 21, 2005, 8:32pm UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/7 "2005-09-21T20:32:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tnetennba](https://avatars.discourse-cdn.com/v4/letter/t/7993a0/32.png) [@tnetennba](https://boards.straightdope.com/u/tnetennba)\
**Post date:** [September 21, 2005, 9:08pm UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/8 "2005-09-21T21:08:19Z")

</div>

> [@fluiddruid](#):
>
> 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
> 
> (C) 2005 Fluiddruid, [fluiddruid@dontspamme.com](mailto:fluiddruid@dontspamme.com)

Cripes, you still use basic?

Try this:

```auto

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.

---

<div class="post-metadata">

**Author:** ![tnetennba](https://avatars.discourse-cdn.com/v4/letter/t/7993a0/32.png) [@tnetennba](https://boards.straightdope.com/u/tnetennba)\
**Post date:** [September 21, 2005, 9:08pm UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/9 "2005-09-21T21:08:28Z")

</div>

> [@fluiddruid](#):
>
> 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
> 
> (C) 2005 Fluiddruid, [fluiddruid@dontspamme.com](mailto:fluiddruid@dontspamme.com)

Cripes, you still use basic?

Try this:

```auto

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.

---

<div class="post-metadata">

**Author:** ![Giraffe](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/giraffe/32/129_2.png) [@Giraffe](https://boards.straightdope.com/u/Giraffe)\
**Post date:** [September 21, 2005, 9:16pm UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/10 "2005-09-21T21:16:04Z")

</div>

> [@tomndebb](#):
>
> Veb and Giraffe aren’t going to like that extra work.

I agree!!!

---

<div class="post-metadata">

**Author:** ![Mtgman](https://avatars.discourse-cdn.com/v4/letter/m/b5a626/32.png) [@Mtgman](https://boards.straightdope.com/u/Mtgman)\
**Post date:** [September 21, 2005, 9:22pm UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/11 "2005-09-21T21:22:32Z")

</div>

> [@tomndebb](#):
>
> 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.

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

---

<div class="post-metadata">

**Author:** ![Mbossa](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@Mbossa](https://boards.straightdope.com/u/Mbossa)\
**Post date:** [September 21, 2005, 11:15pm UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/12 "2005-09-21T23:15:35Z")

</div>

> [@cricetus](#):
>
> Cripes, you still use basic?
> 
> Try this:
> 
> ```auto
> 
> 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.

Undefined variable: n  
😛

---

<div class="post-metadata">

**Author:** ![rjung](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@rjung](https://boards.straightdope.com/u/rjung)\
**Post date:** [September 21, 2005, 11:40pm UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/13 "2005-09-21T23:40:18Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![begbert2](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/begbert2/32/3357_2.png) [@begbert2](https://boards.straightdope.com/u/begbert2)\
**Post date:** [September 22, 2005, 12:00am UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/14 "2005-09-22T00:00:25Z")

</div>

> [@rjung](#):
>
> 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?

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [September 22, 2005, 12:00am UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/15 "2005-09-22T00:00:54Z")

</div>

> [@cricetus](#):
>
> It is, after all, the 21st Century.

So do it the modern way:

```auto

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

```

---

<div class="post-metadata">

**Author:** ![begbert2](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/begbert2/32/3357_2.png) [@begbert2](https://boards.straightdope.com/u/begbert2)\
**Post date:** [September 22, 2005, 12:13am UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/16 "2005-09-22T00:13:43Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![rjung](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@rjung](https://boards.straightdope.com/u/rjung)\
**Post date:** [September 22, 2005, 12:18am UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/17 "2005-09-22T00:18:09Z")

</div>

> [@begbert2](#):
>
> Dude, that code wasn’t _meant_ to be decoded. What are you trying to do, wreck some guy’s job security?

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

---

<div class="post-metadata">

**Author:** ![Idlewild](https://avatars.discourse-cdn.com/v4/letter/i/8491ac/32.png) [@Idlewild](https://boards.straightdope.com/u/Idlewild)\
**Post date:** [September 22, 2005, 12:32am UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/18 "2005-09-22T00:32:46Z")

</div>

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.)

---

<div class="post-metadata">

**Author:** ![tomndebb](https://avatars.discourse-cdn.com/v4/letter/t/b9e5f3/32.png) [@tomndebb](https://boards.straightdope.com/u/tomndebb)\
**Post date:** [September 22, 2005, 12:56am UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/19 "2005-09-22T00:56:57Z")

</div>

> [@](#):
>
> 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.

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

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.)

---

<div class="post-metadata">

**Author:** ![CaveMike](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/cavemike/32/16379_2.png) [@CaveMike](https://boards.straightdope.com/u/CaveMike)\
**Post date:** [September 22, 2005, 1:29am UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/20 "2005-09-22T01:29:56Z")

</div>

> [@fluiddruid](#):
>
> 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
> 
> (C) 2005 Fluiddruid, [fluiddruid@dontspamme.com](mailto:fluiddruid@dontspamme.com)

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.

🙂

[Next page](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722.md?page=2)
