i have finished my ai program , and i needs cleaning up , i think there might be some functions that are declared but never called anywere.
is there an easy way to find them
i have finished my ai program , and i needs cleaning up , i think there might be some functions that are declared but never called anywere.
is there an easy way to find them
maybe your IDE supports such an function. the best way that comes to my mind would be quote out the functions and see if there is a compiler error.
If you don't know what functions are called in your program I think that: you do not make enough comments, or you do not stick to coding conventions, or you do not understand your own code, or your design is bad, or a combination of above.
There are thousands of functions that are not used (in libraries, especially those header-only like STL/Boost).
I disagree. Design changes, and a lot of functions that you write end up becoming unnecessary.
This does not imply bad design. Especially as your program evolves.
Try keeping track of all functions in a bigger project, and make sure they're all used.
That said, some functions, especially utility functions are usually useful to keep around.
I think that design changes (of course depending what the changes are and how often they come) might be a sign of bad coding.
I noticed one thing in my programming style: the more expierienced I am, the more portable code I write. I've always had a utility library used everywhere. This library was changing very often at the beginning (had to rewrite it because I could not extend it easily, debugging was hard, etc).
Now I mostly extend this library, and the more I think how something could be solved, the less time I will spend changing (or even rewriting) it.
Sometimes they may be. But sometimes you know you have the perfect design only to find that something is missing or something doesn't work and you have to redo it all. Happens only too often.
Also, I am sure you've seen that the more time passes and the more you learn, the more differently you begin writing your utility code to be more flexible and safe.
Sometimes you even have the urge to go back and change your older utility functions/classes.
Perhaps this is where that statement, "My best code is written with the delete key," comes from.But sometimes you know you have the perfect design only to find that something is missing or something doesn't work and you have to redo it all.
Gimpel Software Home Page for PC-lint and FlexeLint for C/C++
It will find your unused functions, and so much more!
If you're employed to write software, and you don't have something like this, you're really missing out. It might seem expensive, but the payback is the first bug it finds that you would have spent a day trying to find yourself. Trust me, if you've got a lot of code and you run lint for the first time, you're in for a surprise or two.
Source Navigator
Old: Source-Navigator(TM)
New: BerliOS Developer: Project Summary - Source Navigator NG
This is just an IDE, but the big advantage is that you can export its cross-reference database as a number of text files. This makes it very easy to write a simple(!) perl script to go looking for particular bits of information.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
For MSVS right click the fiunction name, object name, variable name, etc. and select Find all references.
Also you can highlight the desired text and do a find all to find out where that is in the code. This is a simple way to find out if any other code calls a specific function, references an object, etc.