Imagine you want to teach some early intermediate programmers - in as few pages as possible - some basic, useful Java. Maybe a person who already knows some Python or some Swift, or Go, or C#.
My thought is that you could show a page of code that demonstrates the use of a lot of key language and API features. You would annotate the code, and maybe on subsequent pages zoom in on certain lines of code and explain them more carefully. But the idea is that all you get is 5-10 pages total. You might also include a diagram or two.
Here's a rough spec for a small program that might cover a lot of bases:
- Write a program that takes command line arguments.
- If the first argument is "sort" or "-sort", you will sort the subsequent arguments by natural (alphabetic) ordering.
- You'll write the (if appropriate, "sorted") arguments to a text file, and display the average length of the arguments.
- You should make an instance of the class, and show as many reasonable, commonly used language features as you can. Don't go overboard!
- FWIW, I used an ArrayList.
I've attached two pages from one of our Java certification books. This code doesn't do as much as I'm proposing, but it might give you an idea of how the 5-10 pages might end up looking.
What I'm mostly curious about is what such code might look like, and if you think a different spec might be better?