• Post Reply Bookmark Topic Watch Topic
  • New Topic

Challenges in teaching Java / OOP [split]  RSS feed

 
Junilu Lacar
Sheriff
Posts: 11157
160
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NOTE: This thread was split off from here: https://coderanch.com/t/670933/java/java/Highest-card

Campbell Ritchie wrote:There is something very non‑object‑oriented about your code. Java® is supposed to be an object‑oriented language an so many people appear here who appear to be bein gtaught procedural programming.

Julian West wrote:Campbell: One doesn't start programming learning classes and OOP principals first; one begins with the basics: variables, conditional statements, and flow-control.  "Parts of speech" precedes "composition".

Asking someone to write a program is more like asking them to write an essay though, isn't it? To write a good essay, one needs to include composition. I see objects as being somewhat analogous to paragraphs. They sit on the fence between "parts of speech" and "composition" because they are about both "form and structure" and "organization of ideas".
 
Piet Souris
Rancher
Posts: 1983
67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question is: when do you demand someone to write an essay? Does it seem reasonable to expect a beginner to write code as you like to see it? How many years of experience and development did it take you to get to your current level of coding? Make no mistake: when you show us your mastership, it is always a great pleisure to read, wishiing I could do it like that as well. But I'm not up to it yet.
 
Junilu Lacar
Sheriff
Posts: 11157
160
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have to agree with Campbell about the quality of instruction. This is the third or fourth thread that OP has started around the same kind of problem. It's like the instructor has a thing with card games and this design.

The bad thing about these exercises is that they are based on a design that most experienced Java programmers would consider to be poorly suited to Java at best. In another language like C, that particular way of representing cards may be acceptable but in a language like Java, no self-respecting Java programmer would do that. Even if, let's say, you had to work with legacy code that used that representation, I would still translate it to enums that allow me to avoid the kind of programming acrobatics and contortions OP is having to do with Strings.
 
Junilu Lacar
Sheriff
Posts: 11157
160
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Piet: You raise a good point and even my wife often reminds me of the same thing. This is a bit of a dilemma. We see many beginners struggle with both the language syntax and the organization of their programs. In my gut, I feel that grammar and composition are not separate things. There's a lot of interplay between them. Take these two sentences for example:

1: His campaign is not a well-oiled machine.
2: A well-oiled machine his campaign is not.

These two sentences express the same idea but most people will see a certain nuance in the second form and detect a tone of sarcasm that's not as evident in the first. The difference comes from the composition.

I keep thinking back to when I was in school learning Spanish. I spent six years learning memorizing all kinds of Spanish conjugations and grammar rules. After all that, I still have very little to show for it. Outside of very common simple phrases, I am nowhere near fluent nor even able to carry on a simple conversation in Spanish even though I understand many words.

I think the problem with the kind of instruction on Java programming that we see these days is that it's a lot like the way I was taught Spanish. We kept getting fed conjugations and basic grammar rules, and then in the finals, we're asked to write essays.  The problem with that was that we had only been instructed and drilled on grammar. We were never given any instruction or exercises that were focused on organizing ideas in sentences, then grouping multiple sentences into coherent paragraphs, and then arranging those paragraphs into a coherent essay.

This is the same kind of problem we see with the kind of instruction that OP appears to be getting.
 
Junilu Lacar
Sheriff
Posts: 11157
160
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the original thread, Piet Souris wrote:I'm much less worried than you are. When someone makes his first steps, drops on the floor are to be expected; in the end, most of us learn to walk pretty well. And when I was in my very first school year, I counted on my fingers, while nowadays I might triple-integrate some function with a change of base. I bet the professor will come up with some lessons to show the limitations of the current String-based approach, that will be a valuable experience for OP. Just give it some time.

Unfortunately, I don't share your optimism. I have not seen any evidence that it actually happens with any of our posters here. That's why I have a lot of angst about this.
 
Campbell Ritchie
Marshal
Posts: 55761
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On the thread whence this discussion was split, Piet Souris wrote:. . . when I was in my very first school year, I counted on my fingers, . . .
That is the correct way to start learning to count. A couple of years ago my little grandson said he knew the difference between a rectangle and a square: “A square has four sides and they are all the same,” at the same time proving her knew what four means by holding up four fingers. When I was at primary school, I had to do arithmetic for money in my head, and Winston Gutkowski will remind you, that was not in decimal arithmetic. But the important thing is to make the leap from that to:-
I went to the bar and bought three pints of Battleaxe and three packets of crisps; I tendered a ten pound note and a five pound note and was given two two pounds and a fivepence in change. What should I do?
You can learn that a method alters the state of an object without knowing anything about control structures. This is (just about) the first Java® class I ever saw:-Note the encapsulation and data hiding, and simple OO construction. We were using BlueJ (‍), so the toString method was not necessary at that stage. You can do lots with that sort of simple class in a completely OO style before you need to introduce the control structures. There is no need to count on your fingers with a class like that because it is so simple. You can see that whole sentence and paragraph as Junilu says as well as the grammar because the grammar has been kept simple.
 
Campbell Ritchie
Marshal
Posts: 55761
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A few minutes ago, I wrote:. . . . What should I do? . . . .
Answer: query the arithmetic because the correct change is £3.05 and return half of one of the two pounds. I usually return the reverse half and keep the obverse
 
Junilu Lacar
Sheriff
Posts: 11157
160
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell's example is a good one. It shows the need to balance simplicity and relevance. if an example is too simple, you run the risk of trivializing the concept you're trying to demonstrate and the value that it can bring to a program. Make it too complex and you run the risk of overwhelming the student with too much information to process at the same time.

I think what would help is a series of related examples that shows a progression from being less OO to being more OO. This would give beginners the kind of context that we seasoned developers unconsciously draw from our past experience. Context is important and it's something that beginners lack and what the kind of instruction we see being given to students these days fails to provide.
 
Campbell Ritchie
Marshal
Posts: 55761
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu Lacar wrote:Campbell's example is a good one. . . .
Not my example, but Dr E N's. The nice thing about her example is that it is easy to extend. That was the version for the first lecture; in the second lecture we learnt how to half‑fill the vessel. That allows you to introduce arithmetic (computer arithmetic has some peculiarities not seen on a calculator, for example) and how to fill the vessel without overfilling it. You can create a Car class which looks almost the same (but don't tell the newbies that ‍)You now have the opportunity to add an Engine object as a field, which shows composition. It would require changes to that constructor. Two weeks and you are handling complicated objects but keeping the grammar simple. A bit like what I sometimes tell people about pseudocode: make it really simple, with words of one syllable only, so even I can understand it.
 
Piet Souris
Rancher
Posts: 1983
67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good example indeed, however: examples enough for the other way around as well. Two months ago I had to update a VFP program. Now. I'm not unfamiliar with DBM's, but I had never worked with VFP. And knowing nothing of the syntax was a nightmare. How did I do a loop? How could I declare a new variable? I knew what Cursors were, of course.

So, where do you start? And, for whom is a course? I remember Junilu starting a discussion a while ago, about the same subject. My question then was, since it was not clear to me: whet kind of students were we talking abvout? A linguist student, who is supposed just to know enough to follow Chomsky's RTN? Or a student who is supposed to invent the next generation parallel cloud-based optimised compiler? Now, that would make a difference.

In the early 90's, I taught a course about introduction to Actuarial Mathematics. All discrete maths, continuity was hardly touched. The maths requirements were pretty low, but I know I had to prepare the sudents to formula's like:


But I had one and a half year to prepare them for that. Mind you, I had to spend some lessons explaining how the x^y key on a pocket calculator worked. Nightmare, and the course board had plans to make the course more in accordance to the uni's continuous interest and mortality curves, on more than one life, together with a discrete pension paying system, or working with Riemann-Stieltjes integrals, in other words. So I asked what to do about the maths requirements then.

So, basically: for whom is a course important? Is OOP important, or could just as well a course with Basic or VBA be given? Indeed, many OP's here have questions, and the hardest thing for me is to decide how far and in what direction a reply should be. In general, my view is: getting OP's program to run at all, as I see that as the biggest incentive to go on. But since many have other ideas about that, it is kind of up to the first one to reply. And since we do have many skilled repliers around here, that first replier always takes quite some responsibility. But that makes it fascinating as well.

Interesting, but difficult, matter!
 
Julian West
Ranch Hand
Posts: 91
3
Chrome Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu Lacar wrote:NOTE: This thread was split off from here: https://coderanch.com/t/670933/java/java/Highest-card

Campbell Ritchie wrote:There is something very non‑object‑oriented about your code. Java® is supposed to be an object‑oriented language an so many people appear here who appear to be bein gtaught procedural programming.

Julian West wrote:Campbell: One doesn't start programming learning classes and OOP principals first; one begins with the basics: variables, conditional statements, and flow-control.  "Parts of speech" precedes "composition".

Asking someone to write a program is more like asking them to write an essay though, isn't it? To write a good essay, one needs to include composition. I see objects as being somewhat analogous to paragraphs. They sit on the fence between "parts of speech" and "composition" because they are about both "form and structure" and "organization of ideas".


...and nobody is taught composition in grammar school; we are taught grammar first.

...and trumping someone's attempt to learn Java with philosophical points about approach to it teaches nothing.
 
Campbell Ritchie
Marshal
Posts: 55761
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Julian West wrote:. . . ...and nobody is taught composition in grammar school; we are taught grammar first. . . .
That only applies to “dead” languages like ancient Latin and ancient Greek. Which is why the translations all sounded so wooden. I had the good fortune to be the first year to be taught French from audiotapes and film strips (now that takes you back) and not to try learning French from a book.

We experience the difficulty people have in making the leap from procedural programming to objects, and see that so many people never make it. Those of us who had the good fortune to be taught by somebody who understands OO appreciate the difference.
 
Junilu Lacar
Sheriff
Posts: 11157
160
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Julian West wrote:
...and nobody is taught composition in grammar school; we are taught grammar first.

But that's the point we're struggling with. Asking someone to write a non-trivial program is like asking them to write an essay. An essay has a story arc, not just a single thought. So there's a disconnect in the instruction if you're just teaching kids about syntax and control structures, then expect them to come up with a coherent program that actually performs a complex set of inter-related operations.

Julian West wrote:
...and trumping someone's attempt to learn Java with philosophical points about approach to it teaches nothing.

I don't think anyone is trying to "trump someone's attempt to learn" by giving that kind of feedback, nor do I think that it doesn't teach anything. Ultimately, learning is determined by the receiver. If they receive nothing, they will learn nothing. At least we're trying to give them something. Whether or not they learn anything from it is really up to them.

I base this opinion on my training in martial arts. I have been fortunate to have teachers who also point out philosophical aspects, even to beginners. As a beginner, you may not understand any of it and think that it's just a bunch of hokey baloney. After a while, once you become more familiar and practiced with the technical aspects of the art, a lot of that hokey baloney actually starts to make sense. If you remember enough of that "philosophy" and start applying your understanding of it, your technique actually improves tremendously. That's one thing I have noticed with the students who seem to advance more quickly than others. They take the philosophical aspects of the art seriously and actually spend time meditating on them.  That's also the kind of thing I look for when I hire programmers. I don't just look for good technicians, I also look for that desire to go "deeper" and become a craftsman.
 
Julian West
Ranch Hand
Posts: 91
3
Chrome Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:
Julian West wrote:. . . ...and nobody is taught composition in grammar school; we are taught grammar first. . . .
That only applies to “dead” languages like ancient Latin and ancient Greek. Which is why the translations all sounded so wooden. I had the good fortune to be the first year to be taught French from audiotapes and film strips (now that takes you back) and not to try learning French from a book.

We experience the difficulty people have in making the leap from procedural programming to objects, and see that so many people never make it. Those of us who had the good fortune to be taught by somebody who understands OO appreciate the difference.


Chastening the teacher whilst ignoring the pupil helps the student make that leap how?  It doesn't.

I didn't say anything about foreign/second languages; I said "grammar school". 

My analogy was to correlate a specific point; trying to "refute" the analogy doesn't prove anything: nobody learns how to compose theses before learning parts of speech and sentence structure.

Priorities: take care of the immediate need (Help with solving the current assignment) first, then get into the latent needs (OOP, proper approach/instruction, etc.). 
 
Junilu Lacar
Sheriff
Posts: 11157
160
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My personal experience with my son, who is in a CIS program, is that we don't give kids enough credit for being able to understand the kind of ideas that seem to be considered more "advanced" like objects and methods.  He's already taking his second Java programming course and they're still writing mostly public static methods.  I showed him one example from a reply I gave in these forums, where I talked about functional decomposition and assigning responsibilities to objects.  At the time, he said that what I was explaining to him made sense but I wasn't really sure if he actually understood it deeply.

However, the next weekend he came home, he told me how he had showed his roommate, who is also in the CIS program, some of the things he had learned from me. They were working on a Rock-Paper-Scissors program. His roommate had written a very messy implementation. My son said that when he showed his implementation, his roommate said, "Wow, that's so clean!" 

So I think that when you show them what's possible, many kids are able to understand the difference between "good" and "bad" code even when they don't yet have the level of sophistication to be able to write good code. By giving them that context and a way to discern the difference, I think they can learn a lot more than what they currently are being taught.
 
Junilu Lacar
Sheriff
Posts: 11157
160
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think a better way to teach Java "grammar" without compromising and polluting the field for later instruction on "composition" would be to have students start out writing code snippets instead of complete programs. Since they also need to execute their code, you can give them a prototype that they can complete by providing the necessary code snippets. You can design these prototypes so that potentially distracting and intimidating nitty-gritty details are hidden in a superclass. My son's current course materials actually include a custom library that provides things like this. In many of their exercises, they are told to extend a GraphicApplication or ConsoleApplication and they just provide the code that's specific to the problem they're trying to solve. It doesn't go as far as I'd like to see it go because they still end up writing a lot of static methods but it's still a better place to start, IMO.

When you give students a prototype that does certain things in an abstract way, you're already exposing them to abstraction, program organization, information hiding, decomposition and compartmentalization, and segregation of responsibilities. Even if you don't actively discuss these concepts with them, they will be able to see and experience them, albeit without consciously recognizing them as such. I think those aspects about the program will still register in the unconscious part of their brains though and that will give them some context that they can relate to when you do get around to talking about those more "advanced" topics. I bet a teacher will get more knowing looks when he says, "Remember when you called this mysterious getDouble() method in that while-loop exercise? Well, that's an example of an abstraction. Abstraction is when ... blah blah blah. And remember how you extended ConsoleApplication or GraphicApplication? Well, that's an example of inheritance and specialization. Inheritance allows us to ... blah blah blah".

I think you also have to make sure that students understand, at a high-level, what's happening and what they're doing with the prototype. "You're going to start with this code. It does a lot of stuff for you in ways you won't understand yet. Don't worry, we'll examine how all that works later on. The goal of this exercise is to understand how a while-loop works. So for now, just focus on applying what you learned about while-loops and make these parts over here work."

In his Scala programming course on Coursera.org, Martin Odersky does a lot of this sort of thing. He even provides tests that you can use as a kind of rubric for your work. I thought that was very effective and helpful. And because he provided well-written Scala programs as part of the coursework, I was able to recognize poorly structured Scala code that other people had written later on, even with my limited experience in Scala.
 
Julian West
Ranch Hand
Posts: 91
3
Chrome Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I pretty much agree with everyone on the OOP thing.  That was never my point.

What I take IllegalArgumentException with is unconstructively criticising someone's code because of their instructor's approach and without helping them to learn to code at all, let alone properly.

Frequently I see a direct question on a for loop or some specific basic thing and the question may or may not eventually get answered amidst the noise about procedural programming crimes against humanity.

Newbie asks how to properly use capital letters and they get dissed for split infinitives.  (see what I did there)
 
Junilu Lacar
Sheriff
Posts: 11157
160
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think anybody is trying to raise anything to the level of high crimes against humanity or diss anyone -- and yes, I know you're just exaggerating for effect. You make a fair point though, in that some comments may come across as a bit draconian, dismissive, or apathetic, especially when directed at beginners who don't really know any better, so I do think we can all make a conscious effort to be more careful about that kind of thing. Honestly, I do often worry about coming across as condescending or pedantic and there have been a few occasions where I have had to apologize for the unintended tone with which my comments were received.

The problems that others and I point out are real though. We see them demonstrated in more and more posts from students in these forums. I see them when I have to interview/audition twenty candidates in order to fill a single position. And I see it when I look at my son's CIS course syllabus and the work he submits. It doesn't bode well for our profession when only 10% or less of practitioners are even aware of the kinds of problems that poor coding/design practices create and treat the idea of craftsmanship as a passing fad or something that only the hard-core people aspire to. I think the academe plays an important role in addressing this. They need to keep up and help give young people a good foundation of knowledge so that folks in the industry don't have to spend so much time dealing with bad software and re-educating and training new grads about real-world techniques of modern software development.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!