[Chisimba-dev] NetBeans. Is there a way to delete all comments for your source files?

607 views
Skip to first unread message

LSD

unread,
May 5, 2010, 7:46:27 AM5/5/10
to chisimba-dev
Hello All,


When I am developing code, I don't like to delete any lines of code
that I have typed. When I find a better way to code something, I
simply comment out the old code. I also helps me version the module.

So NOW that I am done and happy with my module, I am left with tons of
useless commented code in my source files. I want to know a quick
painless way to delete them all with Netbeans.


Thanks for reading
LSD AKA Salman Noor
MIU Intern

Charl van Niekerk

unread,
May 5, 2010, 7:53:42 AM5/5/10
to chisim...@googlegroups.com
On Wed, 2010-05-05 at 04:46 -0700, LSD wrote:
> When I am developing code, I don't like to delete any lines of code
> that I have typed. When I find a better way to code something, I
> simply comment out the old code. I also helps me version the module.

I also hate deleting code but what I do is commit early and often and
then I have a perfect revision history in case I need to go back later.
And no comment mess accumulating in my code. :)

Jeremy O'Connor

unread,
May 5, 2010, 8:33:45 AM5/5/10
to chisim...@googlegroups.com

On 2010/05/05 01:46 PM, LSD wrote:
> Hello All,
>
>
> When I am developing code, I don't like to delete any lines of code
> that I have typed. When I find a better way to code something, I
> simply comment out the old code. I also helps me version the module.
>
> So NOW that I am done and happy with my module, I am left with tons of
> useless commented code in my source files. I want to know a quick
> painless way to delete them all with Netbeans.
>

Since you developing on Chisimba, I presume you have some background in
Computer Science (i.e. programming theory). You should therefore know
then that this is an insoluble problem. Just think it through a little:
how would a supposed "solution" (or "tool" in your case) be able to
differentiate between "commented out code" and proper comments? Q.E.D.

--Jeremy

Derek Keats

unread,
May 5, 2010, 8:49:08 AM5/5/10
to chisim...@googlegroups.com
It could be done, but you would have to use a convention such as
//--> and then run it through a regular expression.

d

<html><p><font face = "verdana" size = "0.8" color = "navy">This communication is intended for the addressee only. It is confidential. If you have received this communication in error, please notify us immediately and destroy the original message. You may not copy or disseminate this communication without the permission of the University. Only authorized signatories are competent to enter into agreements on behalf of the University and recipients are thus advised that the content of this message may not be legally binding on the University and may contain the personal views and opinions of the author, which are not necessarily the views and opinions of The University of the Witwatersrand, Johannesburg. All agreements between the University and outsiders are subject to South African Law unless the University agrees in writing to the contrary.</font></p></html>

James Scoble

unread,
May 5, 2010, 10:25:33 AM5/5/10
to chisim...@googlegroups.com
>>> On 5/5/2010 at 2:33 pm, in message <4BE165A...@uwc.ac.za>, Jeremy O'Connor
It could delete lines beginning with "//", while ignoring the "/** ... */" comment convention.


Charl van Niekerk

unread,
May 5, 2010, 10:28:47 AM5/5/10
to chisim...@googlegroups.com
On Wed, 2010-05-05 at 16:25 +0200, James Scoble wrote:
> It could delete lines beginning with "//", while ignoring the "/** ... */" comment convention.

Sounds dangerous to me... Am I the only one that has legit comments
inside the actual code starting with //?

Derek Keats

unread,
May 5, 2010, 10:38:49 AM5/5/10
to chisim...@googlegroups.com
On Wed, 2010-05-05 at 16:25 +0200, James Scoble wrote:
>
> It could delete lines beginning with "//", while ignoring the "/** ...
> */" comment convention.


And I CAN drive my car in reverse from Cape Town to Joburg,
but it doesn't mean I should.

Paul Scott

unread,
May 5, 2010, 11:45:03 AM5/5/10
to chisim...@googlegroups.com
This is not really a conversation that I agree with, but I will add R0.02

When commenting proper inline comments, the convention is:

// This is a comment.

Note the space between // and the start of the comment as well as the
punctuation

When commenting code for deletion, you could leave out the space then
use a regex to wipe out all non conforming comments

--
-- Paul

http://www.paulscott.za.net
http://twitter.com/paulscott56
http://avoir.uwc.ac.za

Charl van Niekerk

unread,
May 5, 2010, 12:18:00 PM5/5/10
to chisim...@googlegroups.com
On Wed, 2010-05-05 at 17:45 +0200, Paul Scott wrote:
> Note the space between // and the start of the comment as well as the
> punctuation
>
> When commenting code for deletion, you could leave out the space then
> use a regex to wipe out all non conforming comments

+1, that sounds like a really good convention.

Jeremy O'Connor

unread,
May 6, 2010, 4:36:56 AM5/6/10
to chisim...@googlegroups.com
Yes, one can create many different "conventions", but unless everyone
working on Chisimba follows them, in general the problem remains insoluble.

--Jeremy

Paul Scott

unread,
May 6, 2010, 4:50:52 AM5/6/10
to chisim...@googlegroups.com

Jeremy O'Connor wrote:
> Yes, one can create many different "conventions", but unless everyone
> working on Chisimba follows them, in general the problem remains insoluble.

Well this convention has been around since the beginning of Chisimba. It
is even written into the coding conventions doc and the codesniffer
module that reports these kind of things

Salman Noor

unread,
May 6, 2010, 8:35:43 AM5/6/10
to chisim...@googlegroups.com
Thanks for the wonderful replies,

How can I delete ALL of the comments from my source files.




Reply all
Reply to author
Forward
0 new messages