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())? 🤔
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 ;) ).
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 ❤
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.
@@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 :)
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"
Dr Venkat is the only one that can give a video for IntelliJ Idea using VIM.
❤ the great explanation of the features by Venkat. As usual enthusiastic and fun filled Venkat along with Mala.
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())? 🤔
How does my legend use vim, without any syntax highlighting needs to be investigated😭
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 ;) ).
Perfect explanation ❤
This is awesome!
Subramaniam the best 🏆thank you
Great interview Congratulations Mala
Well explained
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 ❤
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.
@@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 :)
geez his speach pattern is soooo painful to listen to… 🤦♂️🤦♂️🤦♂️
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"