Effective Java - Still Effective After All These Years

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ส.ค. 2024
  • Joshua Bloch serves up a few Java Puzzlers as an appetizer before and as dessert after the main course on Effective Java.
    Organized By: Silicon Valley Web JUG - Van Riper and Kevin Nilson
    Hosted and Sponsored By: Google
    Video By: Marakana
    Event: www.meetup.com/...
    Slides: files.meetup.co...

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

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

    Gotta love the THC joke @ 36-37. This man is a true inspiration.

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

    "misteaks" lol, this guy is a genius

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

    He's a very good orator who has a descent sense of humor.

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

    the #2 returns 1 since the caching is there from -128 to 127. if we change the numbers in the string array from 129 to 133, then we will get -2 as the result while searching for 130

  • @deusaquilusyou
    @deusaquilusyou 11 ปีที่แล้ว +3

    I don't like PECS because Producer/Consumer paradigm is confusing (what's pushAll, it produces into the stack but consumes from the array, which is it???). I like GESS (as in 'guess' more) which stands for Getter-Extends (i.e. the function that gets stuff from data structure arg you pass in uses Extends) and Setter-Super (i.e. the function that sets stuff inside the passed data structure uses Super).

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

    The temperature example at 43:32 is not polymorphic and violates the Open/Closed Principle (OCP). If you add a new unit such as Kelvin, you have to change the already existing class to include a new option into an if or switch statement. In fact, it would be better to have a class Celsius and classes Fahrenheit and Kelvin that can convert from Celsius.

    • @ashwiniabhishek1504
      @ashwiniabhishek1504 ปีที่แล้ว

      Why would I do that, isn't a single parameter of enum type handle that?

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

    Enlightening...Engaging...Effective !!
    Thank You !!

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

    Thanks for sharing!

  • @chauhanvipul2009
    @chauhanvipul2009 10 ปีที่แล้ว

    Very interesting Video, I am loving it.

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

    Thanks, very interesting.

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

    Your Books are great .

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

    Awesome!

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

    This is great!

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

    one of the best

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

    Interesting what he is saying about the serialization proxy. He explained it well. But, would that pattern still be useful in 2015?

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

    14:30 The second question answer is wrong (nowadays). It returns 1, the answer is b. I think the valueOf method has changed since the video, and now it caches them instead of creating new Integers, as long as the Integer value is between -128 and 127. This integer creation from cache works with literals too, like Integer i = 127; (is cached) and Integer j = 128; (is not cached) With two integers compared with == where it's created with 127 it is the same integer and returns true. While with 128 it returns false.
    So with that code it returns 1, and answer b is correct. If Integer.valueOf(s) is replaced with new Integer(Integer.parseInt(s)) It will still return -2, as in the video.
    Also, the best compare method imo is return i - j;
    Here it is obvious you are comparing their values, because it's a subtraction, and you dont need any if statements or ternary operators, or additional variables. The returned value doesn't have to be -1, 0 or 1, just that it's negative, 0 or positive. Very simple.

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

    10:36 Is where the human brain forks a new thread to do a physical maneuver and the original thread blocks and then continues.

  •  12 ปีที่แล้ว

    For the third puzzler I would have used Integer#compareTo(Integer).

  • @larryd9577
    @larryd9577 ปีที่แล้ว

    Isn't putIfAbsent ok to use, if you want to gather stuff without returning it right away?

  • @skmckkie
    @skmckkie หลายเดือนก่อน

    is threre only one video?

  • @hankigoe829
    @hankigoe829 4 ปีที่แล้ว

    Java is the future COBOL, which is good. Please discuss.

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

    super!

  • @hankigoe829
    @hankigoe829 4 ปีที่แล้ว

    The more I learn about Java, the less the hate on it is justified. But it will prolly continue since they're king of the mountain (#1 tiobe this year), and likely will be for years/decades to come.

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

    Hm, example #2 from 11:20 is incorrect. It actually works as expected (tested even on JDK6U45), because of Integer class caches the values from -127 to 128 by default. The return value will be 1.
    public static Integer valueOf(int i) {
    if(i >= -128 && i

    • @awanbiru-ride
      @awanbiru-ride 7 ปีที่แล้ว

      Your suggestion of continuing using reference comparison is dangerous. It explicitly exposed your code a the mercy of platform changes of which outside our control.
      We all strive for code that clearly works not merely works.

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

    Woooosh

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

    While Python generally leads to more compact code, it certainly is not faster than Java if equal care is taken with regards to performance. Most of the time it will be a lot slower than Java, occasionally a little faster in special cases.

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

    Why is he, not using Externalize instead if using Serialization proxy ?

  • @jasonhuang3197
    @jasonhuang3197 10 ปีที่แล้ว +3

    who can tell me why the result of the second puzzle is -2 ? i runed the demo , it truns out to be 1 . i really wanted to know why ! tks advance !!

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

      Same problem,I think, maybe we use the different JDK version.The video is Uploaded on Oct 22, 2009. JDK 7 is released at July 28, 2011.

    • @jakub5975
      @jakub5975 10 ปีที่แล้ว +7

      Wen er The problem is because of the Integer constant pool in Java. In most implementations Integers between -128 to 127 are stored in the pool, so there is only one instance each of them. If you change 1 to 1000, 2 to 2000 etc. and pass 1000 as a binarySearch parameter in the code snippet you'll get expected -2 output.

    • @jasonhuang3197
      @jasonhuang3197 10 ปีที่แล้ว

      Jakub Hruby tks ! i've checked the source code , u r right .

    • @emmetbrown2859
      @emmetbrown2859 10 ปีที่แล้ว

      Wen er
      "HTML5" only. Oy vey.

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

      Jakub Hruby that's correct, thanks.

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

    Aaaaand what programming lang. you are using? :)

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

    @avafanasiev it's noisy sound I ment

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

    非常好

  • @Den-Geist-Befreien
    @Den-Geist-Befreien 4 ปีที่แล้ว +1

    Anyone here in 2020???

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

    He missed the best fix for Searching for the One (18:00) by a mile. It is:
    return i - j;

    • @FeLiNe418
      @FeLiNe418 10 ปีที่แล้ว

      What if it was a long or a double.

    • @JamesPaulWhite
      @JamesPaulWhite 10 ปีที่แล้ว

      FeLiNe418 That would make no difference at all. Why do you think it would?

    • @shirankao69
      @shirankao69 10 ปีที่แล้ว

      Jim White What is ( 1/10f * 1/3f * 3 ) - 1/10f according to your compiler?
      Regardless, it was typed for Integer and your trick would've worked in this case.

    • @JamesPaulWhite
      @JamesPaulWhite 10 ปีที่แล้ว

      shirankao69 It is not a "trick". The definition of Comparable and thus compareTo is directly derived from the mathematical concept of subtraction. The convoluted analysis and solution that Bloch goes through shows he misses this fundamental idea. And the solution for floating types is Math.sign(i - j).

    • @shirankao69
      @shirankao69 10 ปีที่แล้ว

      Jim White No it isn't and you haven't answered my question.

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

    Yesp.

  • @ashwiniabhishek1504
    @ashwiniabhishek1504 ปีที่แล้ว

    I watched this, I must go and flex my pecs😝

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

    I bet it was a...... Mistake
    YYYYEEEEEEEEAAAAAAAAAAAAAAAAAAAHHHHHH

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

    Sorry, but those little dots are NOT all the same color! Are you messing with people? ;)

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

    Duh. Of course it was a joke you silly billy. :)

  • @awanbiru-ride
    @awanbiru-ride 9 ปีที่แล้ว

    Kinda sad somebody actually started trolling here.

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

    Wanting me to grow up? Why should I grow up if I'm 13?? A Spammer is a harder than you thought actually. Try yourself boy. Also. Some respect please :)

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

    c# fanboy

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

    If Java is so bad and you're so smart; feel free to invent your own language. Until you've done that please be quiet.

  • @akarshrastogi3682
    @akarshrastogi3682 5 ปีที่แล้ว

    this guy dances way too much

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

    i hate seeing all these heads. its annoying.

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

    Ahah, 13 and smarter than you, and it feels funny. I can make other programs in C++ more than your Hello Worlds. I made a spammer. But, the only thing I told you was winky tinkys are people that can't accept other languages that C++. Just cause you've been told that it's the best. So for you C++ is a god.

  • @nd-pr1ld
    @nd-pr1ld 7 ปีที่แล้ว

    讲的啥,感觉完全听不懂啊,英文太垃圾了我