DEV Community

Discussion on: A Simple Roadmap for Java Beginners in 2021

Collapse
 
aminmansuri profile image
hidden_dude • Edited

I generally start with objects first.. and teach algorithms later. (to beginners)

But now in 2021 I don't know if I should favor streams rather than classic loops (since it's more OO/functional). What stops me is that Java's stream syntax is somewhat convoluted (compared to Smalltalk or Lisp for example).

Collapse
 
dbc2201 profile image
dbc2201

What I personally feel is, the Streams API is actually not a general "replacement" for the conventional loops, it really shines while processing objects from the Collections Framework.
Conventional iteration using loops is a fundamental part of the language, and should be taught, or so I think. Streams could be introduced as a more meaningful way to iterate over the collections instead of using loops.

Collapse
 
aminmansuri profile image
hidden_dude

I agree in the context of Java itself. But not necessarily in the context of OO.
For/while loops are not "necessary" concepts in the OO style of programming. They are superfluous as Smalltalk itself demonstrates.

So the question is whether one is teaching an OO or functional style of programming or the practicalities of a new programming language. What do we teach first? What learning will be applicable to all languages?

But as I said, the Stream API is a bit clunky and I think it's very unfortunate that they used the word "stream" which is confusing when also talking about "inputstreams".

Thread Thread
 
dbc2201 profile image
dbc2201

Yes, I agree, I have also felt that the branches/loops in the language sometimes feel like the remnants of the imperative style of Java from the old days. But, having said that, sometimes for example, when you're just learning about creating methods in Java (not adhering to strict clean code standards), branches/iterative statements help out understand the general flow of the method's task.

One could start with those, and move their way in by understanding that there are OO principles like SOLID, and design principles in place which help out when you're beginning to design the idea of a "method" in your mind/notebook/whiteboard, though it takes a lot of time to practice them and even more to master them.

I personally took my students through a journey, where we were introduced to the imperative style first, got comfortable with it, then moved on to the OO side of things, got comfortable, then worked our way forward while approaching the functional style at the end. It is not always an easy task, but if we consider other things as prerequisites, the functional approach seems fairly easy at the end.

Ah yes, the nomenclature certainly could have been better, I could not agree more there myself.

Thread Thread
 
aminmansuri profile image
hidden_dude

I've had great results with objects first.
People tend to have a hard time grasping OO after learning the procedural style (I had trouble back in the day). But the opposite is not so. So I always tried to go as OO first as possible. In fact, we start by teaching with a little OO robot rather than the old "Hello World" from the 70s and 80s. So OO is just natural to them.