Quantcast

Maximum PC

It is currently Tue Sep 23, 2014 6:35 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 27 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Best comments found in code, Evar!
PostPosted: Fri Dec 19, 2008 7:42 am 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
http://stackoverflow.com/questions/1846 ... ncountered


Top
  Profile  
 
 Post subject:
PostPosted: Fri Dec 19, 2008 8:01 am 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
Dirty code :)

Code:
Person p = new Person("John", "Doe", "male");
Collection women = new ArrayList();
women.insert(p.getTail());


Top
  Profile  
 
 Post subject:
PostPosted: Fri Dec 19, 2008 9:27 am 
Java Junkie
Java Junkie
User avatar

Joined: Mon Jun 14, 2004 10:23 am
Posts: 24224
Location: Granite Heaven
Some of those comments are priceless!


Top
  Profile  
 
 Post subject:
PostPosted: Fri Dec 19, 2008 4:59 pm 
Little Foot
Little Foot
User avatar

Joined: Mon Jul 28, 2008 1:39 pm
Posts: 123
Yeah... lol

Quote:
It speaks volume about our profession that when asked about the "best comment", we all answer with the worse comments we can find...

My favorite:
Code:
//the useful code begins here
//if you didn't read the first part, then please read this part


Top
  Profile  
 
 Post subject:
PostPosted: Mon Dec 22, 2008 1:39 pm 
8086
8086

Joined: Sun Jan 06, 2008 2:40 pm
Posts: 37
Location: Massachusetts
HAHA, nice post, my favorite:

Code:
// I have to find a better job



Top
  Profile  
 
 Post subject:
PostPosted: Mon Feb 23, 2009 8:53 pm 
8086
8086

Joined: Sun Aug 26, 2007 5:09 am
Posts: 92
i have found it best not to have comments. Its job security :D


Top
  Profile  
 
 Post subject:
PostPosted: Mon Feb 23, 2009 9:18 pm 
Monkey Fed [PC]
Monkey Fed [PC]
User avatar

Joined: Wed Oct 05, 2005 7:53 pm
Posts: 7076
I think there's some zombie in this code.........


Top
  Profile  
 
 Post subject:
PostPosted: Tue Feb 24, 2009 4:38 am 
Java Junkie
Java Junkie
User avatar

Joined: Mon Jun 14, 2004 10:23 am
Posts: 24224
Location: Granite Heaven
comptech08 wrote:
i have found it best not to have comments. Its job security :D


This is probably why you're a compTECH and not a developer.

Documenting code is a job requirement.

As my friend BT implied .. please don't bring dead threads back to life.


Top
  Profile  
 
 Post subject:
PostPosted: Tue Feb 24, 2009 4:45 am 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
comptech08 wrote:
i have found it best not to have comments. Its job security :D
That, unfortunately is NOT job security. At least anymore. An manager worth his salt would see what you did and FIRE you, replacing you with somebody more competent.

Code tells you what, comments tell you why:
http://www.codinghorror.com/blog/archives/001150.html


Top
  Profile  
 
 Post subject:
PostPosted: Tue Feb 24, 2009 10:59 am 
Team Member Top 1000
Team Member Top 1000
User avatar

Joined: Wed Jul 02, 2008 1:41 pm
Posts: 252
lol, nice post

Quote:
# code below replaces code above - any problems?
# yeah, it doesn't f*cking work.


Top
  Profile  
 
 Post subject:
PostPosted: Tue Feb 24, 2009 1:02 pm 
Northwood
Northwood
User avatar

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2261
Location: No. 1 Thread Killer
Quote:
//When I wrote this, only God and I understood what I was doing
//Now, God only knows



Top
  Profile  
 
 Post subject:
PostPosted: Wed Feb 25, 2009 5:07 am 
Java Junkie
Java Junkie
User avatar

Joined: Mon Jun 14, 2004 10:23 am
Posts: 24224
Location: Granite Heaven
Dwood15 wrote:
Quote:
//When I wrote this, only God and I understood what I was doing
//Now, God only knows



How much do you want to bet that the code commented here was written in perl? :lol:

A week after I write a script, or even a complicated regex, it takes me longer to decipher it than it took to write it in the first place. Thank god for proper commenting! :P


Top
  Profile  
 
 Post subject:
PostPosted: Wed Feb 25, 2009 6:18 am 
8086
8086

Joined: Sun Aug 26, 2007 5:09 am
Posts: 92
Jipstyle wrote:
comptech08 wrote:
i have found it best not to have comments. Its job security :D


This is probably why you're a compTECH and not a developer.

Documenting code is a job requirement.

As my friend BT implied .. please don't bring dead threads back to life.


wow hostile. I am not really a coder, and don't really care. lol i know its neccesary geesh are jokes not aloud?

a thread is a thread sorry if i read it later then you wanted me to.


Top
  Profile  
 
 Post subject:
PostPosted: Wed Feb 25, 2009 6:31 am 
Java Junkie
Java Junkie
User avatar

Joined: Mon Jun 14, 2004 10:23 am
Posts: 24224
Location: Granite Heaven
comptech08 wrote:
Jipstyle wrote:
comptech08 wrote:
i have found it best not to have comments. Its job security :D


This is probably why you're a compTECH and not a developer.

Documenting code is a job requirement.

As my friend BT implied .. please don't bring dead threads back to life.


wow hostile. I am not really a coder, and don't really care. lol i know its neccesary geesh are jokes not aloud?


You can make jokes and I can't? :lol:

Jokes that mislead new programmers and reinforce poor coding practices that the industry is desperate to eliminate .. not so much with the funny.


Quote:
a thread is a thread sorry if i read it later then you wanted me to.


A rule is a rule. I recommend you read them before you post. Don't bump threads that are over 30 days old. Please don't mistake this as a request.


Top
  Profile  
 
 Post subject:
PostPosted: Wed Feb 25, 2009 5:32 pm 
Northwood
Northwood
User avatar

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2261
Location: No. 1 Thread Killer
Jipstyle wrote:
Dwood15 wrote:
Quote:
//When I wrote this, only God and I understood what I was doing
//Now, God only knows



How much do you want to bet that the code commented here was written in perl? :lol:

A week after I write a script, or even a complicated regex, it takes me longer to decipher it than it took to write it in the first place. Thank god for proper commenting! :P


What I hate most are comments that confuse more than the actual code does. People giving the epics by Homer all over again in their commenting.

If you thought "The Grudge" was scary...

But honestly, keep comment length to a minimum. Code should be able to tell the story.


Top
  Profile  
 
 Post subject:
PostPosted: Thu Feb 26, 2009 5:22 am 
Java Junkie
Java Junkie
User avatar

Joined: Mon Jun 14, 2004 10:23 am
Posts: 24224
Location: Granite Heaven
Dwood15 wrote:
What I hate most are comments that confuse more than the actual code does. People giving the epics by Homer all over again in their commenting.

If you thought "The Grudge" was scary...

But honestly, keep comment length to a minimum. Code should be able to tell the story.


Absolutely.

Proper documentation of code is actually a difficult thing to master. Done properly, it makes reading the code easy ... the comments and code flow together easily.


Top
  Profile  
 
 Post subject:
PostPosted: Thu Feb 26, 2009 5:35 am 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
With things like intellisense and autocompletion there is ZERO reason (IMO of course) to have stupidly short variable names... such as x and y when you could have nLength and nWidth. Any decent IDE supports this so that you shouldn't have to always type every name.

Sorry to you purists who use a text editor. Get with the times! :)

This makes the code more readable and doesn't require you to document every damn thing you do so that it makes sense.

Comments tell you why.
Code tells you how.


Top
  Profile  
 
 Post subject:
PostPosted: Thu Feb 26, 2009 6:03 am 
Java Junkie
Java Junkie
User avatar

Joined: Mon Jun 14, 2004 10:23 am
Posts: 24224
Location: Granite Heaven
Exactly!

Comments can also tell you how, though. For instance, you should mention the type of algorithm a particular function uses. Reading 'Uses bubble sort' is much easier than reading the function and walking through the first half dozen steps until you figure out which sorting algo you're using.


Top
  Profile  
 
 Post subject:
PostPosted: Thu Feb 26, 2009 12:06 pm 
Team Member Top 1000
Team Member Top 1000
User avatar

Joined: Wed Jul 02, 2008 1:41 pm
Posts: 252
jip, I am going to have to agree with you there, I just had an exam in my class to tell the difference between bubble and selection sort, of course my lack of experience probably had something to do with the amount of time it took me to it but mentally doing algorithims like is a pain, and usually creates a block.

now modern IDEs, like netbeans for example, let you "fold" code and even put a description of it in. This is great when you can just fold functions so you only have to look at the name and not the actual code.


Top
  Profile  
 
 Post subject:
PostPosted: Thu Feb 26, 2009 12:10 pm 
Java Junkie
Java Junkie
User avatar

Joined: Mon Jun 14, 2004 10:23 am
Posts: 24224
Location: Granite Heaven
When you are working with a function, as opposed to writing it, all you should ever need is the interface definition. Properly coded, a function is a blackbox with a set of prescribed inputs and outputs.

So .. yeah .. 'folding' the code in a function is nice feature for any IDE. Makes for much less scrolling through code! :)


Top
  Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 27 posts ]  Go to page 1, 2  Next

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group