I am in the process of trying to untangle the (of course uncommented) code of a contractor that preceded (and I don't have access to currently) me at my current gig and I came across three pieces of code that I found odd and was hoping someone might clue me into why this might have been done, since I can't come up with any valid reason for this I was hoping someone else might clue me in:).
The application is structured as a Java web app, and there are a bunch of JSPs and a handful of servlets. Pretty standard stuff... until I came across four classes that are key to what this application is supposed to do. These classes do not extend HTTPServlet
, but contain a main()
method instead. To make things more confusing, the classes are not referenced anywhere in the project. It's as if they were just dumped in the containing package to avoid creating a new project?
My question in succinct form is this: is there a valid reason to have classes which contain main()
methods contained in a web app?
Not really a valid one, but I've seen people put test code in main methods. It's convenient while you're developing the class, but it's pretty pointless now that there are so many unit test frameworks to choose from.
(Hm. I was tempted to ask if you work at my old company, but judging by the other responses, this is a more common bad practice than I thought.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With