This just adds unnecessary complexity making the code unreadable and un-maintainable. Why not just write for loops and keep it simple? Streams do not provide any performance advantage over loops.
You have a point when it comes to complexity. In general functional style of programming is hard to get at first. It needs getting used to. Streams are very tightly coupled with Generics, Lambda expressions, Method References, Functional interfaces. It's not about performance (though you could argue in some cases you can use parallel streams). When you get used to functional programming, you will find it easier to create complex data structures - it will be less buggy.
@@viraj_shetty Thanks for the reply. I respectfully disagree, it's not about getting used to, it's about writing code that will be understood quickly and can be changed quickly by someone who has never seen the code before. I have seen non-trivial "functional" code that is a complete spaghetti of maps/collectors that spans over 50 lines and no one has a clue what's supposed to happen if we remove one of the "apply" calls :) I only care about performance, if I can save 10 micro-seconds by writing "for" loops, I will do it and "functional" style slows me down. Just my opinion, not that it matters :)
I guess we can write bad code given any tool. You will find functional coding styles now in every programming language.. It's yet another tool in the toolbox. Choose your poison wisely :)
Quality content
Glad you enjoyed !
Please create a udemy course on Core Java (deep dive).
Will try
Yes, please. Do create some extra videos with examples. Better still add in one of your Udemy courses, or create a new one, please.
Will do
This just adds unnecessary complexity making the code unreadable and un-maintainable. Why not just write for loops and keep it simple? Streams do not provide any performance advantage over loops.
You have a point when it comes to complexity. In general functional style of programming is hard to get at first. It needs getting used to. Streams are very tightly coupled with Generics, Lambda expressions, Method References, Functional interfaces. It's not about performance (though you could argue in some cases you can use parallel streams). When you get used to functional programming, you will find it easier to create complex data structures - it will be less buggy.
@@viraj_shetty Thanks for the reply. I respectfully disagree, it's not about getting used to, it's about writing code that will be understood quickly and can be changed quickly by someone who has never seen the code before. I have seen non-trivial "functional" code that is a complete spaghetti of maps/collectors that spans over 50 lines and no one has a clue what's supposed to happen if we remove one of the "apply" calls :) I only care about performance, if I can save 10 micro-seconds by writing "for" loops, I will do it and "functional" style slows me down. Just my opinion, not that it matters :)
I guess we can write bad code given any tool. You will find functional coding styles now in every programming language.. It's yet another tool in the toolbox. Choose your poison wisely :)