Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I've been imparting a Java introduction course for several years. Some slides explain how to read from files and keyboard using BufferedReaders, InputStreams, FileInputStreamReaders etc.

I'm adding slides explaining how to achieve this using newer approaches like Scanner.

Should I leave out the old BufferedReaders, InputStreams and FileInputStreamReaders slides altogether, and teach only the new methods, or should I continue to teach these methods for the sake of completeness ?

Will my students benefit from learning how to read from files and keyboard the old way ?

share|improve this question

6 Answers 6

up vote 11 down vote accepted

To be frank, they're both the "old" way. Most of the time, developers in industry read files from an SQL, XML, JSON, or similar library, and most read from the keyboard from an android TextView or similar.

The reason you teach the old ways isn't because that's what a programmer will be using every day, it's to provide a foundation they can fall back on if their abstractions ever leak. Someday they might come across an interface where they need to do it the hard way. It might even be in a language other than Java. That's when the foundational knowledge comes in handy. They will know they can handle reading a stream a byte at a time, with all the caveats, because they have done it before in school.

share|improve this answer

Instead of teaching them you could explain their presence and then go on to say how the new methods are better and teach those. I'm generally interesting in hearing how languages evolve and that itself may be a lesson for your students.

share|improve this answer
    
+1 BufferedReaders, InputStreams and FileInputStreamReaders are a little bit tricky to catch by newbies and requiere a certain amount of exercises. Would it be necessary for them to learn to use them before going into the easier Scannerpart ? –  user61852 Oct 31 '12 at 2:51

Is your course vocational training of academic focused. If vocational, most of your students going to be expected to write code for existing systems and be expected to know "The old ways" of doing stuff (if they want a job). How you approach that is an interesting problem - you can ignore it, glance over it in passing or use it as an example to them of why they need to know "The old ways", even though it's not always better.

A good approach is to introduce the easiest ways first, let them learn how to do that well, then have some assignments introducing other methods while discussing history and pros and cons of each.

share|improve this answer
    
+1: "legacy" Java code may not use Scanner so it's good to know the "old-way" and the "new-way" –  Deco Oct 31 '12 at 3:37
    
+1 It's an in-company, internal course so all programmers and maintainers eventually get to know Java in order for them to be able to be rotated as maintainers of Java apps, or into Java developer teams. –  user61852 Oct 31 '12 at 3:37

Yes, why not both. Teaching how it used to be and why it changed can give a better understanding of the language and programming in general (my emphasis on 'why').

share|improve this answer

Also look to Java 7's NIO file and I/O handling with try-with-resources. As others have said, certainly cover the past and how the language evolved for the needs of today!

share|improve this answer

Keep in mind that we in industry don't just write new code, we maintain old code too (probably even more). I would definitely update your slide deck so that you teach students the newest technology, but I also think it's worthwhile to spend some time showing them the older I/O methods so they'll recognize them when the see them in the wild.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.