- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
ah, jackcess. I once used it in an AWS lambda to transfer the data from an Access db to a Db in the AWS environment. The code and the architecture were admittedly horrible. and I hope this code is not still in use, but OTOH I wouldn't doubt that one of my successors will eventually post my code to TDWTF
Admin
Dunno. Maybe it's my lack of specific knowledge of these things, but this line of code makes me ... uneasy:
Is it normal to pass a class object to a logger?
Admin
It does (in its own special way) propogate the exception - after a transformation <wink>..
In some languages
is perfectly Valid provided Method is not virtual, and does not acces any member variables :) :) :)
Admin
Yes, Logger.getLogger(ResultLoader.class) is not just a normal thing, it is the correct way to initialize logger.
Admin
I'm assuming that the logging system has a map of object -> logger, so that you can handle logging in different ways (such as logging at different levels, or have separate log files) in different parts of the system. That line would just mean that all logging from the class is kept together. It isn't a WTF on its own, though it may be part of a WTF (such as if they have the logging set up to use a different file for every class).
Admin
@Log // use Lombok everyone else does.
Admin
The class passed to
getLogger
is used for a couple things:debug
ortrace
logging while tracking down a bug).Admin
nobody commenting on the last
Result result = new Result(00, new Date(), consumptions);
that doesn't get returned?Admin
This may be because the snippet was changed a bit to not reveal too much information, but in the line instantiating the "Result" object: Where does the "consumptions" come from? And why is the "result" object not used/returned after creation?
Admin
The whole story became clear when I saw the programmer call it "Jackcess" in a comment. I was immediately on his side.
I'm reminded of the client I worked with for some years. They weren't small. Perhaps 400 employees. But at some point, not too long before I began helping them, someone made the decision to maintain all company data in Access. Then came the need to have a company website on their intranet. Somehow, they were managing employees and manufacturing traffic via Access. Such a nightmare. Little by little I migrated to SQL server, but the data was still a mess. Fun times.
Admin
Steve, we often either pass a class or the name of a class to the Logger. There is a configuration file which can set the logging level based on package (or subpackage!) or class. The configuration file also indicates where to log the messages (syserr, sysout, or some file) and the format to use.
Admin
Remy, unless that snipped-out code has side-effects, loadResult will do nothing except iterate over the entire table. Also, we can't see what "consumptions" is (but if new Result has a side effect there it's a gigantic wtf) and the "yearConsumption" map just falls out of scope. It's plenty wtfy.
Admin
Maybe class Result is DAO and stores automatically on construction data in database table? Aka, yes have fun with (side)effects… Also everything is static. I suspect there might be more fun then article covered...
Admin
I have a different gripe: the exception in the first method is treated to a printStackTrace(). Does this automagically end up in Logger? If not, dubbelyouteheff.
Admin
A place where I worked built their own ASPx logging framework which could send emails with the error (not entirely unuseful), but insisted on two things: The application be built in three layers (Data Access, Business Logic and Presentation) and each layer use this logging framework. So if a database call failed, you'd get three emails. And if a database server went down, you'd get flooded x 3 with error messages. I'm retired now. I'm retired now. I'm retired now.