JEP Explained. JEP 482: Flexible Constructor Bodies

Поделиться
HTML-код
  • Опубликовано: 27 окт 2024

Комментарии • 15

  • @wandacode
    @wandacode 2 месяца назад +4

    Dr Venkat is the only one that can give a video for IntelliJ Idea using VIM.

  • @nagamohank2244
    @nagamohank2244 2 месяца назад +2

    ❤ the great explanation of the features by Venkat. As usual enthusiastic and fun filled Venkat along with Mala.

  • @ITV-ITV-
    @ITV-ITV- 2 месяца назад +1

    So... this allows for breaking SRP in class constructors and defeating the need for Factory pattern in exchange for the extra job for compiler engineers (extra checks for the call to super())? 🤔

  • @sphesihlemanuel2933
    @sphesihlemanuel2933 2 месяца назад +5

    How does my legend use vim, without any syntax highlighting needs to be investigated😭

    • @Quillraven
      @Quillraven 2 месяца назад

      most likely it is faster for demonstration purposes and not so "bloated". I personally liked his way of presentation a lot and was not hard to follow the code (coming from a JetBrains fanboy ;) ).

  • @Poisonedyouth79
    @Poisonedyouth79 2 месяца назад

    Perfect explanation ❤

  • @wazeeharaa8100
    @wazeeharaa8100 2 месяца назад

    This is awesome!

  • @ahmedurmiteahmedurmite3711
    @ahmedurmiteahmedurmite3711 2 месяца назад

    Subramaniam the best 🏆thank you

  • @iscjorgerg
    @iscjorgerg 2 месяца назад

    Great interview Congratulations Mala

  • @JPilsonSumbo
    @JPilsonSumbo 2 месяца назад

    Well explained

  • @Quillraven
    @Quillraven 2 месяца назад

    Just watched the first 10 minutes but isn't it anyway a bad practice to throw exceptions in your constructor? Just add a factory method, do the validations first and only if successful create a valid instance of your object.
    At least that is how I (and many others out there) solve it.
    edit: presentation was excellent though for this part ❤

    • @benfowlie5147
      @benfowlie5147 2 месяца назад +1

      Short answer, it depends.
      If there is no object hierarchy, then that is the way to go according to Effective Java.
      But when there is a hierarchy with validation at every level, then this way leads to duplication of the validation logic, a static factory method cannot call another static factory method to initialize the parent objects.
      It's better to throw from a constructor than to initiate an invalid state.

    • @Quillraven
      @Quillraven 2 месяца назад

      @@benfowlie5147 hm okay, I guess I never faced this scenario because I try to avoid extending classes if possible. I have seen too many codebases where a class inherits from an abstract class which again inherits from an abstract class, etc., etc. and you end up with 3+ levels of a hierarchy where noone understands anymore what is happening where and what happens when you touch a function of one of the "middle" classes.
      However, I get your point but still I personally find it confusing that a "new ObjectXYZ()" will throw an exception. Anyway, there are so many different scenarios out there and I can imagine that in some of them this might be the best solution. So, thanks for the input :)

  • @Alperic27
    @Alperic27 Месяц назад

    geez his speach pattern is soooo painful to listen to… 🤦‍♂️🤦‍♂️🤦‍♂️

  • @pavelpetrashov2975
    @pavelpetrashov2975 2 месяца назад

    What is going on with Java? Please, stop doing it! I am sure an army of smart developers are going to use this doomy "feature" and this "relaxing" is going to turn many projects into a garbage. Please, don't do have logic in yhe constructor! Just duplicate you validation method if you need it will be even better (not it will be still wrong) than this "feature"