warn me on unused methods

  • Thread starter Thread starter Martijn Mulder
  • Start date Start date
M

Martijn Mulder

A nice feature of the csc.exe compiler is that it warns you if a variable is
declared but never used. But unused methods are not flagged, even when the
warning level is set to 4.
 
That suggestion obviously couldn't be applied across the board. But,
I'm having a hard time trying to think of a compelling arguement
against checking private methods for use. Anyone?

Brian
 
The only argument I can think of is to check private methods for use.
However, I honestly don't see this as a very useful feature.

It is very common to have a variable declared and used, then change the
code, and now it is no longer needed.

It's hard to imagine having frequent scenarios of entire methods being
written but never used.

For me, this would be at the very bottom of lists of priorities in terms of
compiler enhancements.
 
My 'bottom-up' approach to programming could certainly benefit from a
compiler that warns for unused private methods. I write very much very small
private methods, one, two, sometimes three lines long, that I assemble into
bigger chunks. The good old 'Lego' approach. It is what makes programming
fun to me. But when I finally have the functionality that I wish, many many
of these methods have no use. The 'weeding' of the code is also fun, all
those hours work and now I throw it away! I enter 'Zen' mode and use a
two-step approach: 1) comment out what might be useless by now and try to
compile; 2) restore the code if compilation fails, otherwise delete it.

You understand that a list of unused private methods would help.
 
Hello Martijn,

And what's the problem? Do u want to find unused methods or what?
There 2 two solutions
1) use ReSharpert tool - it shows in gray collor unused methods
2) use NCover tool - this tool shows which function was called during run
programs. If you have good unitTests then after running all tests with NCover
u will see which functions were untouched

MM> A nice feature of the csc.exe compiler is that it warns you if a
MM> variable is declared but never used. But unused methods are not
MM> flagged, even when the warning level is set to 4.
MM>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsch
 
The problem is that I use 2 sharp tools, an editor (vim.exe) and a compiler
(csc.exe) and that I'm not really interested in learning new tools where a
simple compiler switch could suffice


MN> And what's the problem? Do u want to find unused methods or what?
MN> There 2 two solutions
MN> 1) use ReSharpert tool - it shows in gray collor unused methods
MN> 2) use NCover tool - this tool shows which function was called during
run
MN> programs. If you have good unitTests then after running all tests with
NCover
MN> u will see which functions were untouched

MM> A nice feature of the csc.exe compiler is that it warns you if a
MM> variable is declared but never used. But unused methods are not
MM> flagged, even when the warning level is set to 4.
MM>
 
Hello Martijn,

I suppose such tools like nUnit and NCover are worth being learned :)

MM> The problem is that I use 2 sharp tools, an editor (vim.exe) and a
MM> compiler (csc.exe) and that I'm not really interested in learning
MM> new tools where a simple compiler switch could suffice
MM>
MN>> And what's the problem? Do u want to find unused methods or what?
MN>> There 2 two solutions
MN>> 1) use ReSharpert tool - it shows in gray collor unused methods
MN>> 2) use NCover tool - this tool shows which function was called
MN>> during
MM> run
MN>> programs. If you have good unitTests then after running all tests
MN>> with
MN>>
MM> NCover
MN>> u will see which functions were untouched
MN>>
MM>> A nice feature of the csc.exe compiler is that it warns you if a
MM>> variable is declared but never used. But unused methods are not
MM>> flagged, even when the warning level is set to 4.
MM>>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsch
 
Michael, I never touched a debugger in my life. They scare the hell out of
me ;-)
 
Hello Martijn,

These tools are not debuggers, they only help to make you code more perfect
:)

MM> Michael, I never touched a debugger in my life. They scare the hell
MM> out of me ;-)
MM>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
Hello Michael,

I am terribly sceptic about things. Anti wrinkle cream, it will give you
wrinkles. Debuggers, they introduce bugs. Code streamliners, sure to break
your code. But you seem like a nice person to me so I will investigate the
tools that you recommend. Thanks for your time


MN> These tools are not debuggers, they only help to MN> make you code more
perfect
:)

MM> Michael, I never touched a debugger in my life. They scare the hell
MM> out of me ;-)
MM>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top