addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupshelp-with-circleimageimagesinstagramlinklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

Re: [ljc] Re: Defender Methods

From: Kevin W.
Sent on: Tuesday, August 21, 2012 10:30 AM
If every single implementation of List, Set, Queue, Iterator, etc. has to provide an implementation of  the new lambda-capable methods (map, filter, et al) then it would be the most extreme violation of the DRY principle that the world has ever seen since CSS was invented.

Want to write a "throw-away" iterator...?  You'd have to drop a tonne of extra code into the otherwise lightweight implementation, time and time again.

This is about pushing back against the extremes of boilerplate that modern Java seems to have evolved, just as much as it's about backwards compatibility.  So no, it's not a "temporary fix"; it's a much needed, significant, and very welcome addition to the language for evermore.

On 21 August[masked]:57, Abraham Marín Pérez <[address removed]> wrote:
Replying to my own question about a scenario for defender methods, I read the example of backwards compatibility for interfaces. I see the usefulness of that, but I understand that in that scenario defender methods are meant to be sort of temporal (ie, eventually all clients will implement the new method and hence the default implementation would be removed). However, I'd like to know if there is any situation where a default implementation would be left permanently in the interface as a design decision.


Abraham Marín Pérez
Sent from my iPhone

On 21 Aug 2012, at 03:48, Abraham Marín Pérez<[address removed]> wrote:

Doesn't that defeat the very purpose of single class inheritance? It sounds like a hack to have multiple class inheritance: If I do interfaces where all methods are defender methods then I can mock multiple class inheritance.

I'm just trying to find a scenario where this could be useful.


On 20 Aug 2012, at 19:58, Kevin Wright <[address removed]> wrote:

On 20 August[masked]:45, Abraham Marín Pérez <[address removed]> wrote:
This might be a silly question but... What's the difference between an interface with a default method and an abstract class with an implementation for that method?

Java has multiple interface inheritance, but single class inheritance.  You could, potentially, inherit defender methods from multiple parents.

Kevin Wright
mail: [address removed]
gtalk / msn : [address removed]
vibe / skype: kev.lee.wright
steam: kev_lee_wright

"My point today is that, if we wish to count lines of code, we should not regard them as "lines produced" but as "lines spent": the current conventional wisdom is so foolish as to book that count on the wrong side of the ledger" ~ Dijkstra

Our Sponsors

  • Our Blog

    Read the latest news from the LJC

  • RecWorks Ltd

    Fixing Tech Recruitment using the Power of Community

  • jClarity

    Java/JVM Performance Analysis Tools & mentoring for Java related matters

  • LJC Aggrity

    Our LJC Aggrity site contains blog posts from our members

  • LJC Book Club

    Our Book club with book reviews from our members

  • Devoxx UK

    Java Community Conference in collaboration with the LJC, 8-10th June 16

  • SkillsMatter

    "Host, help organise, promote, film many of our meetings."

  • IBM

    Build Enterprise-grade apps at start-up speed.

  • New Relic

    New Relic makes sense of billions of metrics a day in real time.

  • Hazelcast

    Hazelcast is the leader in operating in-memory computing.

  • Java.Net

    We are an official Java User Group recognised by Oracle's JUG program

  • JRebel

    Free 3 month J-Rebel license.

  • O'Reilly

    40% discount on printed books and 50% on e-books.

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy