Received: by 10.66.86.166 with SMTP id q6mr590370paz.44.1355382597218; Wed, 12 Dec 2012 23:09:57 -0800 (PST) Received: by 10.50.108.200 with SMTP id hm8mr178277igb.10.1355382597001; Wed, 12 Dec 2012 23:09:57 -0800 (PST) Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!nntp.club.cc.cmu.edu!newsfeed.news.ucla.edu!usenet.stanford.edu!kt20no15878913pbb.1!news-out.google.com!6ni40484pbd.1!nntp.google.com!kt20no15878908pbb.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.java.programmer Date: Wed, 12 Dec 2012 23:09:56 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=69.28.149.29; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T NNTP-Posting-Host: 69.28.149.29 References: <7f36342c-2331-4484-874b-4a0f8953f160@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: multi-line Strings From: Lew Injection-Date: Thu, 13 Dec 2012 07:09:57 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: csiph.com comp.lang.java.programmer:20289 William Bonawentura wrote: > Consider something like this: > > @Inject > @Resource( "message1" ) > private String message1; Works a treat. I recently had occasion to work up an annotation to cover some ugly, testable but twisted reflective code. Writing the annotation gave multiple advantage, many quite unforeseen. - Boilerplate code vanishes from annotated call sites. - Leaving behind short, easy-to-comprehend routines. - DRY - all the magic moves into one class that handles the annoation. - Since you're in ReflectionLand anyway, you get a lot of data for logging calls. - Orthogonal treatment - other code and tooling can use the same annotations in novel ways with zero influence on existing consumers. - Annotations contribute to self-documentation at least as much as boilerplate detracts, squaring the benefit to code literacy. - Adding modules to the system using the same annotation is super easy. - When another programmer returned from leave, they were able to jump right in and add another module the same day, leveraging the annotation. JPA annotations are a good example of some of those bullet points. Even though in this particular case I was one of the main proponents of the annotation approach, I am still stunned at how well it worked. Oh, that brings up another benefit. Intra-team communication around implementations using the annotation is accelerated. It's largely because with an annotation there's nothing to talk about once you've developed it. I had to explain the boilerplate a lot, which is part of what led to writing the annotation. No one yet has needed an explanation of the annotation beyond how its 'value' attribute connects it to the rest of our lattice, and that but once. -- Lew