Google I/O 2009 - Big Modular Java with Guice

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 ก.ย. 2024
  • Google I/O 2009 - Big Modular Java with Guice
    Dhanji R. Prasanna, Jesse Wilson
    Learn how Google uses the fast, lightweight Guice framework to power some of the largest and most complex applications in the world. Supporting scores of developers, and steep testing and scaling requirements for the web, Guice proves that there is still ample room for a simple, type-safe and dynamic programming model in Java. This session will serve as a simple introduction to Guice, its ecosystem and how we use it at Google.
    For presentation slides and all I/O sessions, please go to: code.google.com/events/io/sessions.html

ความคิดเห็น • 53

  • @marcusaureliusfanboy
    @marcusaureliusfanboy ปีที่แล้ว +8

    14:30 till this point, they explain why to use DI in the first place
    14:40 why Guice?
    16:52 Bindings
    24:15 Scopes
    28:12 Defining injections
    30:55 Injecting providers
    32:45 Leveraging Guice
    41:00 AOP
    43:45 Introspection SPI
    47:30 how to compose modules

  • @SumanthVepa
    @SumanthVepa 3 ปีที่แล้ว +25

    "Wave uses guice, why aren't you". Yeah. That didn't age well.

  • @allyourcode
    @allyourcode 13 ปีที่แล้ว +7

    @7:38 But if you are using JUnit (and it looks like you are), you can (and probably should) perform setup and tear down in the setUp and tearDown methods.

  • @allyourcode
    @allyourcode 13 ปีที่แล้ว

    @4:15 Another way would be to have overridable (i.e. non-final) methods that return a Shortener (and another one that returns a Tweeter). That way, you can write a subclass that overrides those methods with their own implementations that return mocks, or whatever.

  • @mtilsted
    @mtilsted 13 ปีที่แล้ว

    @eelakh
    True, but javac don't so it depend on which compiler you use.

  • @Dzimboo1
    @Dzimboo1 3 ปีที่แล้ว +5

    who is 2021 in?

  • @arsathish
    @arsathish 14 ปีที่แล้ว +1

    guice-servlet module, seems to be like going back. we moved the configuration from servlet code to XML in early 2000 and now we are going back..

  • @captainhastings3761
    @captainhastings3761 ปีที่แล้ว +2

    R.I.P Bob!! :(

  • @rajeshviswanathan2764
    @rajeshviswanathan2764 ปีที่แล้ว +2

    RIP Bob Lee. :(

  • @zhenfan2725
    @zhenfan2725 4 ปีที่แล้ว +2

    watching this in 2020

    • @TehBrian
      @TehBrian 3 ปีที่แล้ว

      mood

  • @MirajGodha
    @MirajGodha 6 ปีที่แล้ว +5

    Why Reinventing Spring?

    • @cybernessful
      @cybernessful 3 ปีที่แล้ว +1

      Why reinventing inversion of control?

  • @asteriondaedalus6859
    @asteriondaedalus6859 7 ปีที่แล้ว +3

    Reinventing Spring? Nah! They are reinventing Borland JBuilder.

  • @rajeshvasudevana
    @rajeshvasudevana 15 ปีที่แล้ว

    Good presentation ! thanks

  • @eragon841
    @eragon841 14 ปีที่แล้ว

    It would still have been a direct dependency, every class that goes into an if block has to be imported (i.e. loaded and initiated).

  • @DragoTama
    @DragoTama 11 ปีที่แล้ว

    I think that the point there is that the setup and teardown are boilerplate, no matter if you do it manually or using the JUnit methods.
    Using Guice you are supposed to not even need to setup and teardown.

  • @alexwastakenwastaken
    @alexwastakenwastaken 4 ปีที่แล้ว +8

    "Google Wave uses it" loool!

  • @krellin
    @krellin 10 ปีที่แล้ว +11

    Why reinventing Spring? there is nothing I saw in this video that could convince me to use Guice instead of Spring. And I'm not even talking about other Spring Projects...

    • @alucard87
      @alucard87 9 ปีที่แล้ว +1

      because guice is typesafe and spring is not?

    • @krellin
      @krellin 9 ปีที่แล้ว

      My post was a while ago, i dont really remember everything i saw about guice, but with proper ide support you have type safety even in your xmls... anyway thats not an argument to switch to anything else... spring provides not only DI it gives a lot of awesome technologies to develop serious enterprize apps... i doubt that with guice you could easily use spring security or spring data or any other component...

    • @bbugarschi
      @bbugarschi 9 ปีที่แล้ว +6

      Vachagan Balayan i guess its a matter of preference. i like guice because it has modules that you could, in theory at least :P, reuse in other apps without copy+pasting the beans.xml. however spring is more of a "kitchen sink" framework, it has way more features compared to guice. it more like a eco-system where guice is more of a lib.

    • @yilativs
      @yilativs 7 ปีที่แล้ว +3

      Spring is type safe.

    • @theren8311
      @theren8311 6 ปีที่แล้ว +1

      github.com/google/guice/wiki/SpringComparison

  • @starbase18portugal
    @starbase18portugal 15 ปีที่แล้ว

    great vid!

  • @eelakh
    @eelakh 13 ปีที่แล้ว

    At around 7th minute Jesse says if you compile a module you have to compile everything that it depends on?!!! it's not true. Test for yourself if you don't believe me. Define a class and inside one of the methods call another class that you've defined compile it. Then see the time of creation of the class files. Then go back and change the dependent class and compile again. It will still work without needing to compile the other class again. IDEs also keep track of these dependencies

  • @offmyjacks
    @offmyjacks 12 ปีที่แล้ว +2

    Soo pretty much this is a re-write of Spring.

    • @aquavxi6431
      @aquavxi6431 3 ปีที่แล้ว

      @Deonex What do you mean? Im noob with Spring, and I discover this... jejej.

  • @shalomshachne
    @shalomshachne 12 ปีที่แล้ว

    Hey guys - what do you think the junit setup/teardown methods are for... Not saying DI isn't needed, but your unit test makes a poor argument...

  • @phonkey
    @phonkey 11 ปีที่แล้ว

    That's right! That is the Hollywood sign. Very good!

  • @DrewSpencer
    @DrewSpencer 12 ปีที่แล้ว +11

    "Well Google wave uses it, so why aren't you?" Shhh!

  • @allyourcode
    @allyourcode 11 ปีที่แล้ว

    Sorry, forgot to mention @13:54

  • @eatcodesleeprepeat9133
    @eatcodesleeprepeat9133 5 ปีที่แล้ว +1

    Another good google guice tutorial at :
    th-cam.com/play/PLp0ed20U4R4jknb4xYdhx3yJn5RhWECxn.html

  • @Discofunk007
    @Discofunk007 13 ปีที่แล้ว

    Don't like that there is a dependency on Guice for the annotations (or is there?). Should default to use the constructor with the most parameters

  • @AFromPoland
    @AFromPoland 15 ปีที่แล้ว

    Nope, he couldnt use else in this method, because text local variable can be changed in the first if block of code (see: text = shortener.shorten(text);).

  • @sriharshacv7760
    @sriharshacv7760 7 ปีที่แล้ว

    Can you share the links to the presentation. The link mentioned above doesn't work.

  • @ertreri
    @ertreri 12 ปีที่แล้ว

    one question though, when you are configuring your depencies in a module, at the end of the line/tree, your leaf dependencies will always have to be classes with no argument constructors, correct? There is no way, that you can configure juice to just inject you a class depends on a Long, for example. You would have to wrap that long in some wrap long class with a no argument constructor, or something of the sort. So, for example, if the smsTwitter need a Locale as input, that would be the end.

  • @ebuzertahakanat
    @ebuzertahakanat 8 ปีที่แล้ว

    one word : WELD

  • @tivrfoa
    @tivrfoa 15 ปีที่แล้ว

    Why he didn't use "else" in the first code? =)

    • @jamesflames6987
      @jamesflames6987 ปีที่แล้ว +1

      Both code blocks are intended to run.

    • @LeandroCoutinho
      @LeandroCoutinho ปีที่แล้ว +1

      @@jamesflames6987 my question from 13 years ago. Thank you! yes, the first if updates 'text'

  • @kumarkashyap3996
    @kumarkashyap3996 2 ปีที่แล้ว

    24:34

  • @muralive
    @muralive 15 ปีที่แล้ว

    I love Guice but don't quite like the infomercial style of making every other way look so ugly at the beginning of the video.

  • @FrankConnolly8
    @FrankConnolly8 11 ปีที่แล้ว +2

    I thought it was shadow until I read your comment! Worst. Beard. Ever.

    • @ggsay1687
      @ggsay1687 3 ปีที่แล้ว

      I used to have that kind of beard 😆

  • @yilativs
    @yilativs 7 ปีที่แล้ว

    what stops them from creating with new TwitterFactory("mockTestSmsProviderUrl") and not dealing with ugly static methods that won't work in multi-threading environment anyway and will make them always to write a tearDown method to cleanup parameters passed via static method? (i'm talking about th-cam.com/video/hBVJbzAagfs/w-d-xo.htmlm20s example)

  • @jrodjuiceman
    @jrodjuiceman 10 ปีที่แล้ว +4

    I thought Juice was spelled with a J not G.
    GUICE. JUICE
    GONE. JUNGLE
    GET. JET
    GATHER. JUSTICE
    Maybe that's why my nickname is "JuiceMan" go figure, lol.

    • @IsaacCheng8
      @IsaacCheng8 5 ปีที่แล้ว +4

      When we make discovery or invention, we should always give it a unique name, preferably a short memorable non-word, because most publications are read by machines these days. For example, "p53" is a far better gene name than "her" as the latter is likely to be filtered out by a stoplist of common words, missing out great opportunities of cancer cure discovery by machine learning. By the same token, "guice" is more googleable than "juice." Good job, Google!

  • @utsavgupta
    @utsavgupta 14 ปีที่แล้ว +3

    Hollywood principle "don't call us, we'll call you."
    Bollywood principle "call us, we won't call you. No balance dude!"
    Haha... No offense, just a joke!