drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Barclay <dbarc...@maprtech.com>
Subject Re: dropping qualified names in logger declarations
Date Wed, 22 Jul 2015 17:51:46 GMT

Chris Westin wrote:
> For the special case of the logger, I kind of like it this way, because I
> can turn it off just by commenting out a single line (to get rid of
> unreferenced variable warnings),or add it by pasting in or uncommenting a
> single line. In either case I don't have to worry about removing or adding
> the import line separately, which can be quite far away if there are a lot
> of imports.

Why not use the modern Java feature intended for cases like this:  have
a @SuppressWarnings("unused") annotation on the logger member
declaration if the declaration has been added but the member isn't used

- We can still avoid unused-variable warnings for logger members that
   have already been declared before there are any uses.
- We no longer have to move up top to adjust an already-existing logger
   declaration when adding a logger use down in the code.
   (Yes, we should remove (or comment out) the annotation if the change
   isn't temporary, but we don't have to do that immediately just to
   continue compiling.)
- We can now use code completion when adding the first logger call to a
   previously unused logger, since the declaration is real (not just a
- We can still comment out/uncomment only a single line (the annotation)
   to switch between the no-logger-uses and some-logger-use cases.  (That
   is, if you don't want to have to re-add the suppression annotation if
   the last use of a logger is removed later, you can comment out, rather
   than delete, the annotation when the first logger use it added.
- We no longer have to either go adjust imports or use qualified names
   to avoid having to adjust imports.
- We stop having unnecessarily qualified names in the code.
- and, finally ...:
- We stop having those names' extra visual clutter and length, which
   makes it harder to notice when the class literal ends up wrong.
   (Note the mention of "pasting" above.)


> On Tue, Jul 21, 2015 at 6:12 PM, Daniel Barclay <dbarclay@maprtech.com>
> wrote:
>> For logger member declarations, can we drop the current pattern of using
>> qualified names (like this:
>>    private static final org.slf4j.Logger logger =
>> org.slf4j.LoggerFactory.getLogger(StoragePluginRegistry.class);
>> ) and allow using imports and non-qualified names (as we do for almost
>> everything else)?
>> Using qualified names adds a lot of visual noise, and pushes the class
>> literal farther to the right, making it easier to fail to notice that
>> it doesn't match the containing class.
>> Thanks,
>> Daniel
>> --
>> Daniel Barclay
>> MapR Technologies

Daniel Barclay
MapR Technologies

View raw message