You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dave Newton <ne...@pingsite.com> on 2005/09/29 17:57:56 UTC

[OT] Re: writing images from a database

Braun, James F wrote:

>I didn't mean for this to become debate.
>
Yeah, good luck with that.

*lol*

As you've discovered, some people are more interested in being uppity 
than actually helping with the core question :/

>          byte[] bytes = new byte[1024*1024]; // some maximum size
>          int byteSize = pictureStream.read(bytes); // read in the bytes
>          byte[] bytesX = new byte[byteSize]; // create a new array of
>the proper size
>          for(int i=0;i<byteSize;i++) { // copy them into the new array
>            bytesX[i] = bytes[i];
>          }
>          pictureBytes = bytesX; // assign it to the form variable
>        }
>  
>
People like me ;)

Oh god remove the comments. Bottom line: if someone can't figure out 
what's going on here w/o relying on the comments then they're fired.

Java is already like crack for people that like to type; why make it 
worse with redundant commentary?

Just a pet peeve of mine ;)

Dave



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [OT] Re: writing images from a database

Posted by Dakota Jack <da...@gmail.com>.
Lord, if there were gigabytes of comments that would be bad. 
Horrible.  A disaster.  Something to cry about.  However, there are
not.  So that is good.  Very good.  Something to smile about.  If
there is anything like a whole bunch of comments, that is the sign of
an amateur and the same is true about no comments and unreadable code.

On 9/29/05, Murray Collingwood <mu...@focus-computing.com.au> wrote:
> On 29 Sep 2005 at 19:11, Frank W. Zammetti wrote:
> > Murray, have you ever actually had a compiler choke on a source file
> > because of comments?!?  *That* might be the harm indeed! :)
>
> There were a couple of times when I had to consider the cost of disk space vs the value
> of a program.  When the comments in your source code start consuming gigabytes of
> disk space I think everybody should start asking these same questions.... and not
> before.  ;-)
>
> Kind regards
> mc
>
>
>
>
> FOCUS Computing
> Mob: 0415 24 26 24
> murray@focus-computing.com.au
> http://www.focus-computing.com.au
>
>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.0.344 / Virus Database: 267.11.9/115 - Release Date: 29/09/2005
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


--
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


[OT] Re: writing images from a database

Posted by Murray Collingwood <mu...@focus-computing.com.au>.
On 29 Sep 2005 at 19:11, Frank W. Zammetti wrote:
> Murray, have you ever actually had a compiler choke on a source file 
> because of comments?!?  *That* might be the harm indeed! :)

There were a couple of times when I had to consider the cost of disk space vs the value 
of a program.  When the comments in your source code start consuming gigabytes of 
disk space I think everybody should start asking these same questions.... and not 
before.  ;-)

Kind regards
mc




FOCUS Computing
Mob: 0415 24 26 24
murray@focus-computing.com.au
http://www.focus-computing.com.au



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.11.9/115 - Release Date: 29/09/2005


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [OT] Re: writing images from a database

Posted by Dakota Jack <da...@gmail.com>.
I think the idea is to make code clear.  If you cannot possibly make
the code clear without comments, then put the comments into the code. 
Gratuitous comments are counter-productive.

On 9/29/05, Dave Newton <ne...@pingsite.com> wrote:
> Frank W. Zammetti wrote:
>
> > Let me ask this question... what's the HARM in "read in the bytes"?
>
> Having comments that are superfluous:
> (a) still requires brain processing, and my brain is in short supply :/
> (b) obscures what's actually being done (see note below)
> (c) requires maintenance
>
> Note: If comments like that are well to the right and justified along
> some far-right column I'd be slightly mollified as it keeps them out of
> the way.
>
> ...but I've never been through a code review where those comments
> wouldn't have been tagged for deletion. They're just not helpful (in
> this specific case).
>
> > Murray, have you ever actually had a compiler choke on a source file
> > because of comments?!?
>
> I tweaked a compiler during college to do fun things when it encountered
> naughty words in comments. That was fun.
>
> Dave
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


--
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [OT] Re: writing images from a database

Posted by Dave Newton <ne...@pingsite.com>.
Frank W. Zammetti wrote:

> Let me ask this question... what's the HARM in "read in the bytes"?

Having comments that are superfluous:
(a) still requires brain processing, and my brain is in short supply :/
(b) obscures what's actually being done (see note below)
(c) requires maintenance

Note: If comments like that are well to the right and justified along 
some far-right column I'd be slightly mollified as it keeps them out of 
the way.

...but I've never been through a code review where those comments 
wouldn't have been tagged for deletion. They're just not helpful (in 
this specific case).

> Murray, have you ever actually had a compiler choke on a source file 
> because of comments?!?

I tweaked a compiler during college to do fun things when it encountered 
naughty words in comments. That was fun.

Dave



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [OT] Re: writing images from a database

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Let me ask this question... what's the HARM in "read in the bytes"?

Murray, have you ever actually had a compiler choke on a source file 
because of comments?!?  *That* might be the harm indeed! :)

Frank

Dave Newton wrote:
> Murray Collingwood wrote:
> 
>> I agree with Frank, we all started with Java/Struts somewhere and back 
>> then the more comments in the code made it so much easier for us to 
>> understand.
> 
> If you're documenting functionality, I totally agree.
> 
> If you're commenting "inputStream.read(xxx)" with "read in the bytes" I 
> couldn't disagree more.
> 
> Dave
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 
> 
> .
> 

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [OT] Re: writing images from a database

Posted by Dave Newton <ne...@pingsite.com>.
Norris Shelton wrote:

>It is better to be over-documented, than under.  Also, I would
>use the full package name on objects.  Nothing is more fun than
>trying to figure out an object when it's in more than one
>package (like ALL the client certificate code) or it's in some
>library that you have never seen.
>  
>
Slightly agree, but again, in general, this usually over-obfuscates (for 
me, anyway :)

Part of why I say that is because I almost never touch Java code outside 
of an IDE these days: I hover, it tells me what I need to know; I 
double-click an can go to the declaration, etc.

I'd probably use a comment here rather than messing with the mainline 
code, though.

In my own code it's pretty rare I'll have an in-line comment. I'll 
comment large functional blocks of code, and I JavaDoc most everything 
pretty thoroughly (except packages, which I need to get in the habit 
of). That said I rarely have methods that are very long, I use 
descriptive variable and method names, and that seems to eliminate most 
confusion.

Dave



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [OT] Re: writing images from a database

Posted by Norris Shelton <no...@yahoo.com>.
Yes and no.  

If it's his production code no, but if it's a how-to or
something that goes in a wiki, it should leave no details
uncovered.  

It is better to be over-documented, than under.  Also, I would
use the full package name on objects.  Nothing is more fun than
trying to figure out an object when it's in more than one
package (like ALL the client certificate code) or it's in some
library that you have never seen.

--- Dave Newton <ne...@pingsite.com> wrote:

> Murray Collingwood wrote:
> 
> >I agree with Frank, we all started with Java/Struts somewhere
> and back then the more 
> >comments in the code made it so much easier for us to
> understand. 
> >
> If you're documenting functionality, I totally agree.
> 
> If you're commenting "inputStream.read(xxx)" with "read in the
> bytes" I 
> couldn't disagree more.
> 
> Dave
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 



Norris Shelton
Software Engineer
Sun Certified Java 1.1 Programmer
Appriss, Inc.
ICQ# 26487421
AIM NorrisEShelton
YIM norrisshelton



		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [OT] Re: writing images from a database

Posted by Dave Newton <ne...@pingsite.com>.
Murray Collingwood wrote:

>I agree with Frank, we all started with Java/Struts somewhere and back then the more 
>comments in the code made it so much easier for us to understand. 
>
If you're documenting functionality, I totally agree.

If you're commenting "inputStream.read(xxx)" with "read in the bytes" I 
couldn't disagree more.

Dave



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [OT] Re: writing images from a database

Posted by Dakota Jack <da...@gmail.com>.
This is directly contrary to best practices.  What really would have
helped in Struts would have been if someone had discussed some of the
naming conventions prior to committing them.  They are particularly
bad in Struts.  However, best practices is to make the code clear
first.  If that is not possible, only then comment.  OP

On 9/29/05, Murray Collingwood <mu...@focus-computing.comau> wrote:
> I agree with Frank, we all started with Java/Struts somewhere and back then the more
> comments in the code made it so much easier for us to understand.  The people who
> come after us will also be learning, let's make it easier for them.
>
> The only time you should reduce comments is when your compiler times-out while
> parsing your source code.
>
> Kind regards
> mc
>
> On 29 Sep 2005 at 12:20, Frank W. Zammetti wrote:
>
> > On Thu, September 29, 2005 11:57 am, Dave Newton said:
> > > Oh god remove the comments. Bottom line: if someone can't figure out
> > > what's going on here w/o relying on the comments then they're fired.
> >
> > Well now, *this* is a good way to go off-topic in a hurry Dave! :)
> >
> > I personally feel just the opposite... the more comments the better, and I
> > don't generally care how "pointless" they are... well, ok, if I see:
> >
> > a++; // Add 1 to A
> >
> > ... I tend to groan rather loudly, but that's a bit extreme :)  When your
> > talking about all the myriad classes available in Java, it's virtually
> > impossible to remember them all, what their methods do, etc.
> >
> > For instance, take this line:
> >
> > String s = s1.toUpperCase().trim().replace('A', '-');
> >
> > Now, that's pretty straight-forward.  But, if someone added a comment:
> >
> > // Convert s1 to all upper-case, trim whitespace from both ends and
> > replace all A's with -'s and store result in s
> >
> > I wouldn't frown upon that for two reasons... one, me looking at it
> > doesn't have to remember what replace() does (i.e., does it replace ALL
> > occurances of 'A' or just the first?) and two, it indicates that the
> > developer who wrote it knew what he intended to do and wrote the code
> > accordingly.
> >
> > So for me, the more comments the better, even if they are commenting on
> > what is an obvious thing for most.
> >
> > Frank
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> >
> > --
> > No virus found in this incoming message.
> > Checked by AVG Anti-Virus.
> > Version: 7.0.344 / Virus Database: 267.11.8/114 - Release Date: 28/09/2005
> >
>
>
>
> FOCUS Computing
> Mob: 0415 24 26 24
> murray@focus-computing.com.au
> http://www.focus-computing.com.au
>
>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.0.344 / Virus Database: 267.11.8/114 - Release Date: 28/09/2005
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


--
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [OT] Re: writing images from a database

Posted by Murray Collingwood <mu...@focus-computing.com.au>.
I agree with Frank, we all started with Java/Struts somewhere and back then the more 
comments in the code made it so much easier for us to understand.  The people who 
come after us will also be learning, let's make it easier for them. 

The only time you should reduce comments is when your compiler times-out while 
parsing your source code.

Kind regards
mc

On 29 Sep 2005 at 12:20, Frank W. Zammetti wrote:

> On Thu, September 29, 2005 11:57 am, Dave Newton said:
> > Oh god remove the comments. Bottom line: if someone can't figure out
> > what's going on here w/o relying on the comments then they're fired.
> 
> Well now, *this* is a good way to go off-topic in a hurry Dave! :)
> 
> I personally feel just the opposite... the more comments the better, and I
> don't generally care how "pointless" they are... well, ok, if I see:
> 
> a++; // Add 1 to A
> 
> ... I tend to groan rather loudly, but that's a bit extreme :)  When your
> talking about all the myriad classes available in Java, it's virtually
> impossible to remember them all, what their methods do, etc.
> 
> For instance, take this line:
> 
> String s = s1.toUpperCase().trim().replace('A', '-');
> 
> Now, that's pretty straight-forward.  But, if someone added a comment:
> 
> // Convert s1 to all upper-case, trim whitespace from both ends and
> replace all A's with -'s and store result in s
> 
> I wouldn't frown upon that for two reasons... one, me looking at it
> doesn't have to remember what replace() does (i.e., does it replace ALL
> occurances of 'A' or just the first?) and two, it indicates that the
> developer who wrote it knew what he intended to do and wrote the code
> accordingly.
> 
> So for me, the more comments the better, even if they are commenting on
> what is an obvious thing for most.
> 
> Frank
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 
> -- 
> No virus found in this incoming message.
> Checked by AVG Anti-Virus.
> Version: 7.0.344 / Virus Database: 267.11.8/114 - Release Date: 28/09/2005
> 



FOCUS Computing
Mob: 0415 24 26 24
murray@focus-computing.com.au
http://www.focus-computing.com.au



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.11.8/114 - Release Date: 28/09/2005


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


BEA Weblogic vs. Eclipse

Posted by Steve Beaver <st...@comcast.net>.
Does anyone have a preference between BEA Weblogic Workshop and
Eclipse 3.1 using TomCat

Thanks



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [OT] Re: writing images from a database

Posted by Dave Newton <ne...@pingsite.com>.
Frank W. Zammetti wrote:

>Well now, *this* is a good way to go off-topic in a hurry Dave! :)
>  
>
I'm sorry, I have a cold. (Marginally obscure Monty Python reference. 
Every OT post needs one.)

I didn't mean to start a debate here?

>I personally feel just the opposite... the more comments the better, and I
>don't generally care how "pointless" they are... well, ok, if I see:
>
>a++; // Add 1 to A
>  
>
         byte[] bytes = new byte[1024*1024]; // some maximum size
         int byteSize = pictureStream.read(bytes); // read in the bytes  
*oh, so _that's_ what 'read' does*
         byte[] bytesX = new byte[byteSize]; // create a new array of  
*oh, so _that's_ what 'new' does*
the proper size
         for(int i=0;i<byteSize;i++) { // copy them into the new array 
*oh, so _that's_ what '=' inside a loop does*
           bytesX[i] = bytes[i];
         }
         pictureBytes = bytesX; // assign it to the form variable *wait, 
I already know what '=' does, but this isn't in a loop*
       }

But all those *are* "add 1 to A" comments.

Besides the fact that the copy chunk should be refactored, you could 
comment the entire block of code by saying "copy input stream to form 
variable."

And I generally would use either an accessor or some sort of "this is an 
instance variable" marker (like _pictureBytes or whatever) to remove one 
more needless comment.

I like comments (love 'em!) but commenting every line in a 5-line chunk 
of code is... silly. This example is obfuscating rather than clarifying.

>String s = s1.toUpperCase().trim().replace('A', '-');
>
>Now, that's pretty straight-forward.  But, if someone added a comment:
>
>// Convert s1 to all upper-case, trim whitespace from both ends and
>replace all A's with -'s and store result in s
>  
>
There's some sort of limit function here. As comment character count 
approaches code character count something horrible happens. My head 
explodes, and maintaining the comments becomes more cumbersome than 
maintaining the code.

This is coming from someone that comments rather heavily, but sensibly.

Dave



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [OT] Re: writing images from a database

Posted by Michael Jouravlev <jm...@gmail.com>.
On 9/29/05, Frank W. Zammetti <fz...@omnytex.com> wrote:
> For instance, take this line:
>
> String s = s1.toUpperCase().trim().replace('A', '-');
>
> Now, that's pretty straight-forward.  But, if someone added a comment:
>
> // Convert s1 to all upper-case, trim whitespace from both ends and
> replace all A's with -'s and store result in s
>
> I wouldn't frown upon that for two reasons... one, me looking at it
> doesn't have to remember what replace() does (i.e., does it replace ALL
> occurances of 'A' or just the first?) and two, it indicates that the
> developer who wrote it knew what he intended to do and wrote the code
> accordingly.

Way too much for me. The only case I would appreciate comment in the
situation above, is when replace() were something like replaceAll() or
matches(). The comment would explain what regex is supposed to
describe.

Michael.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [OT] Re: writing images from a database

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
On Thu, September 29, 2005 11:57 am, Dave Newton said:
> Oh god remove the comments. Bottom line: if someone can't figure out
> what's going on here w/o relying on the comments then they're fired.

Well now, *this* is a good way to go off-topic in a hurry Dave! :)

I personally feel just the opposite... the more comments the better, and I
don't generally care how "pointless" they are... well, ok, if I see:

a++; // Add 1 to A

... I tend to groan rather loudly, but that's a bit extreme :)  When your
talking about all the myriad classes available in Java, it's virtually
impossible to remember them all, what their methods do, etc.

For instance, take this line:

String s = s1.toUpperCase().trim().replace('A', '-');

Now, that's pretty straight-forward.  But, if someone added a comment:

// Convert s1 to all upper-case, trim whitespace from both ends and
replace all A's with -'s and store result in s

I wouldn't frown upon that for two reasons... one, me looking at it
doesn't have to remember what replace() does (i.e., does it replace ALL
occurances of 'A' or just the first?) and two, it indicates that the
developer who wrote it knew what he intended to do and wrote the code
accordingly.

So for me, the more comments the better, even if they are commenting on
what is an obvious thing for most.

Frank

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org