If you could give me some insight, I would be very grateful.
Regards, Vivek C [ February 10, 2008: Message edited by: C Vivek ]
Originally posted by C Vivek: Im thinking it would be a performance hit if unnecessary includes are added.
This is where people run into trouble with performance. They think something will improve performance and jump through all sorts of hoops to go with their assumptions. A wise man once said: premature optimization is the root of all evil. Your first question should be: can one measure the performance hit that unnecessary includes incur? If not, how will you measure the improvement and justify the time you spend fixing them? In any case, I would think unused includes have no effect at runtime, along the lines of using "import *" versus "import classname".
Something that might be a complete aside (I'm not a JSP developer), but seems worth mentioning, is that Eclipse warns me when I have unused import statements (a setting in the compiler options).
As Joe and Steve have said, it's not a performance hit, but I'm sure it's not great programming practice to have them lying around, especially if there are lots of them - it's part of our style guide at work to remove any unnecessary imports that we happen upon.
[Edited for clarity] [ February 07, 2008: Message edited by: David Payne ]
That is what we are here for, improving the work of others makes us reconsider our own work. I often gather useful utilities doing nothing but going around and answering questions. It is fine points like this that distinguish effective work from blunder and bluster.
"The differential equations that describe dynamic interactions of power generators are similar to that of the gravitational interplay among celestial bodies, which is chaotic in nature."
Probably the biggest performance hit would be at compile time, since the compiler has to add this stuff to places to look to resolve things. A good optimizing compiler isn't going to pass on deadwood into the output class, however.
On the other hand, it's untidy and confusing to carry a lot of useless lint, so I prefer to keep my source relatively clean. Not 100%, since a lot of times the references are going to happen in a later edit, but at least get rid of the worst of things.
The Elipse Java source editors can easily clean up an individual source file. Just open for editing and do CTRL+SHIFT+O. Eclipse will also flag unused imports for your convenience. You can probably also clean up imports at the package (folder) level. It does that for similar features, which makes bulk cleanup much more convenient.
Customer surveys are for companies who didn't pay proper attention to begin with.
Joined: Sep 17, 2006
Originally posted by Tim Holloway: Probably the biggest performance hit would be at compile time, since the compiler has to add this stuff to places to look to resolve things. A good optimizing compiler isn't going to pass on deadwood into the output class, however.(...snip...)
So the practice of using full package names at each variable declaration is a tradeoff involving how many books you need to read ( using compile time to read and reconsider ) / how much code there is on the page ( at some point imports are just plain needful ) / nature of the development environment ( some teams value slow response )
The Real-Time Specification for Java always mirrors to Real-World Specificaton in my day to day coding. For what that is worth to the original posters insight: Even a well preened program has some init() to do, and after a few hundred iterations of a core loop, the compiler and BLTN will have removed far greater performance bogs than can possibly be tweaked out of the source code by hand. The suggestion here is to comtemplate how such a tool would be written in Java - the work may result in something that is useful in an unforseen niche.
Netbeans has a command, you right click in the file and it pops up a "fix imports" command. It adds the missing ones, and removes unused ones.
But as Joe said upthread, this smells like premature optimization to me.
Joined: Oct 03, 2004
I was trying to be a bit clever in my new organisation. There are huge numbers of unused include's in almost every JSP which I presumed clogged up the bandwidth. For some strange reason, we dont have Eclipse or Netbeans, may be a licensing problem or something else. We only use Notepad to write JSP's and then FTP them to the server. I work for in technology department in a one of the biggest banks in India, which uses a software from another vendor. We only get to customize a few things and full fledged access is unfortunately not there. Direct access to database is also not possible. Anways my sincere thanks to all of you! If you live around Mumbai, a beer's on me!
Joined: Jun 26, 2002
Both eclipse and netbeans can be used free of charge. Certainly just about any tool would be better than notepad. JEdit is another nice one.
Joined: Oct 03, 2004
Originally posted by steve souza: Both eclipse and netbeans can be used free of charge. Certainly just about any tool would be better than notepad. JEdit is another nice one.
Thanks Steve, The problem is that I dont even have access to the Webserver. I can only write JSP's and FTP them to a specific folder in a separate server. The DBA then picks it up and deploys it under webapps directory.
All I have is a bunch of JSP's in a development folder which are transfered to the webserver. Even to change a ';' I need to follow the same procedure. Eclipse/Netbeans wont be helpful because all includes will be lying in the webserver.
BTW, Is it ok if I just put jamon.war under webapps for JAMon to run? I have placed the war file in the lib directly though!
Regards Vivek C
Joined: Sep 17, 2006
Originally posted by C Vivek:
We only use Notepad to write JSP's and then FTP them to the server.
Try Textpad - Textpad syntax files. They are programmers, the editor runs as fast as Notepad and allows massivly large files to be swapped around efficiently. The gains in your effort from using Textpad are remarkable. The also have something called Wild Edit which may in fact do what you want - be extremely dilligent in retaining backups that are available if you use it. The tool does not see if the import is needed, it just does the command issued.
You can as well setup a small server which will run jsp locally to test before uploading, goolgle for Tomcat.
<< I can only write JSP's and FTP them to a specific folder in a separate server.>> Well that is all you need. If you are editing a jsp in notepad it is easier and less error prone to do it in an editor that can understand java syntax. You can edit locally and ftp over when you are done.
<<BTW, Is it ok if I just put jamon.war under webapps for JAMon to run? >> Yes. however you must put the jamon jar file (jamon-2.7.jar) file at the server level lib directory. Of course you should also configure your apps to use jamon in some manner. It requires no code changes to ue the jamon jdbc driver, log4j jamon appender, or the jboss/tomcat valve. Directions are at www.jamonapi.com for all that I have mentioned.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com