aspose file tools*
The moose likes Java in General and the fly likes Mr. Bloch - Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Mr. Bloch - Java "conductive to quality and prductivity, and a joy to work with"" Watch "Mr. Bloch - Java "conductive to quality and prductivity, and a joy to work with"" New topic
Author

Mr. Bloch - Java "conductive to quality and prductivity, and a joy to work with"

Johannes de Jong
tumbleweed
Bartender

Joined: Jan 27, 2001
Posts: 5089
Mr Bloch, first of all a very big welcome
Re your statement :
"I have found the Java programming language and its libraries to be immensely conducive to quality and productivity, and a joy to work with." see: Amazon
Maybe it's because I'm stupid or its because of my background (I'm a mainframe procedural programmer), but I find your statement to be inaccurate and creates false impression of Java.
I personally find Java a very difficult language to learn. My main problem is the API. It is extremely �painful� to find anything in the API.
I�ll use an example.
Here in the Cattle Drive we have an assignment � OOP-3 (SortNames)�.
Its objective is : �Load an ArrayList with Strings from a text file of names. Show the names sorted in order of first name and then by last name without modifying the strings or the ArrayList.�
I�ll take you through the steps I used to solve this:
  1. Go to the API and find Arraylist
  2. Scan ArrrayList�s own methods � no sort
  3. Scan inherited methods � no sort
  4. Ok then off to check out the Implemented Interfaces � no sort
  5. I�ll write my own method that sorts the Arraylist
  6. Got �nitpicked�, its not the way its supposed to be done � use the interface!!
  7. I give up - I�ll try and find an example/help on the WWW

  8. Know surely this does not make for productivity and/or a joy to work with. I�ll give you the benefit of the doubt on the quality
    I find it frustrating to say the least. Now maybe it�s a �simple� matter of building up my knowledge and my own �library� off classes (examples) and to get used to working with the API.
    I see in the Table of contents of your book that you have a section in the book Know and Use the Libraries (chapter 7. General Programming)
    Do you actually show one how to �effectively� work with the API ??. If you do bring on that book of yours
    ps. I finally found Sort it�s a method in the Collections class. But to my disgust I find myself unable to explain how ArrayList inherits/implements it
    pse note this thread is not meant as a criticism or attack on you as a person.

    [This message has been edited by Johannes de Jong (edited July 10, 2001).]
Geoff Griffiths
Greenhorn

Joined: Mar 18, 2001
Posts: 17
of course a much easier way of searching the API is to use the DocFather3 utility whic can be access eiher online or as a downloadable applet at http://java.sun.com/docs/searchabledocs.html
hope this helps. I found it very useful myself.
Johannes de Jong
tumbleweed
Bartender

Joined: Jan 27, 2001
Posts: 5089
Thanks Geoff
I'm passing it on to the students doing the Cattle Drive.
Jason Menard
Sheriff

Joined: Nov 09, 2000
Posts: 6450
The joy of working with Java and it's libraries is especially evident if you've had to program in C or C++. In order to get much of the same functionality that Java has, in these languages you have to either program it yourself, or use a third party library.
So all you really have to do in Java is take the time to become familiar with the libraries, which in the grand scheme of things, isn't that big of a deal I don't think. And for the most part, the JavaDocs make it pretty simple to figure out how to use a library you are not familiar with.
Jason
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4419
    
    5

Originally posted by Johannes de Jong:
I find your statement to be inaccurate and creates false impression of Java.
I personally find Java a very difficult language to learn. My main problem is the API. It is extremely �painful� to find anything in the API.


Johannes,
YMMV - Your mileage may vary. Mr Bloch was expressing his own personal opinion and experience. As such, I don't think you can say that his statement is inaccurate nor do I think that he meant to mislead in any way. Sure, the API can be overwhelming at first and it takes a while to be able to find your way around the documentation. But once you become familiar with the way it is organized, it isn't that hard to find things.
Personally, I have found the online API JavaDocs to be very useful (especially when trying to answer things here in JavaRanch ). The JavaDocs index is very useful. I tried to see if I could find a sort() method in the index and it didn't take me two minutes to find Collections.sort(List). Click on a few hyperlinks and I find out that ArrayList is a List.
I just got the book the other week and have started reading it. I get sidetracked though because I have so many things to learn about Java: J2EE, EJB, RMI, JMS, JNDI, JDBC, etc. But from what I have seen of the book so far, it looks like it's going to be one that stays at the top of my messy desk pile. And if I'm lucky enough to win this giveaway, I might let you have it instead

[This message has been edited by JUNILU LACAR (edited July 10, 2001).]


Junilu - [How to Ask Questions] [How to Answer Questions]
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
I think Java's API is extremely easy to browse through, once you get the hang of knowing how to search through it. I'm a newbie to Java, but I found myself able to use methods and classes relatively easily once I got the grasp of object-oriented design. Perhaps JdJ the problems you are facing do not stem from Java, but instead from the transition you are making from mainframe to a language that is fully OO (I don't know much about mainframes, so this is an assumption). Learning object-oriented concepts in general might be extremely beneficial to getting a good grasp on Java!
Also, if you read the assignment on OOP-3, it states:
Use the Collections class for sorting.
This class of course contains the needed method for this assignment, you just need to figure out what method to use, and understand the parameter's you pass to it. I agree, this assignment was tough, but I think I have been able to excel much further in Java than any other language I have tackled, mostly because of the accessibility of source and the way in which it is modeled.
Enough ramblin', back to chasin' dem cows!
Jason
[This message has been edited by jason adam (edited July 10, 2001).]
Joshua Bloch
Author and "Sun God"
Ranch Hand

Joined: May 30, 2001
Posts: 124
Johannes,
Hi. I'm sorry that you find Java "a very difficult language to learn." I understand your frustration with the large number of APIs. The libraries do seem imposing, and more are added in every release.
My book implicitly addresses this by (largely) restricting itself to java.lang, java.util and (to a lesser extent) java.io. These packages comprise the "core" of the libraries. There is an item devoted to the libraries (Item 30, "Know and use the libraries"), and it has this to say:
"The libraries are too big to study all the documentation, but every programmer should be familiar with the contents of java.lang , java.util,and, to a lesser extent, java.io. Knowledge of other libraries can be acquired on an as-needed basis."
The problem that you cited concerns a class from java.util, so I think it's actually worth familiarizing yourself with it. In fact, it concerns a class that's part of the Collections Framework. I wrote this framwork so I'm admittedly biased here, but the book has this to say:
"It is beyond the scope of this item to summarize all the facilities in the libraries, but a few bear special mention. In the 1.2 release, a Collections Framework was added to the java.util package. It should be part of every programmer�s basic toolkit."
I'd encourage you to check out the Collections tutorial (http://java.sun.com/docs/books/tutorial/collections/index.html). Once you've worked your way through it, problems like the one you cited will be a breeze. You won't have memorized every method in every class, but you'll know the structure of the Collections Famework, so you'll know right where to turn. (For example, all of the reusable algorithms that operate on collections are in java.util.Collections.)
You say:
ps. I finally found Sort it�s a method in the Collections class. But to my disgust I find myself unable to explain how ArrayList inherits/implements it.
ArrayList neither inherits nor implements java.util.Collections. Collections is an example of a non-instantiable Utitlity Class (See Item 3, "Enforce noninstantiability with a private constructor"). It contains only static methods that operate on instances of the various collection interfaces. ArrayList implements List (as implied by its name). The Collections.Sort method takes a List.
To summarize, I feel your pain; the Java platform has way too many libraries to know all of them, and it just keeps growing. That said, do familiarize yourself with java.lang, java.util and (to a lesser extent) java.io! It's worth the time it takes.

------------------
Joshua Bloch
Author of Effective Java


Joshua Bloch <br />Author of <a href="http://www.amazon.com/exec/obidos/ASIN/0201310058/ref=ase_electricporkchop" target="_blank" rel="nofollow">Effective Java</a> and coauthor of <a href="http://www.amazon.com/exec/obidos/ASIN/032133678X/ref=ase_electricporkchop" target="_blank" rel="nofollow">Java Puzzlers</a>
Johannes de Jong
tumbleweed
Bartender

Joined: Jan 27, 2001
Posts: 5089
All your comments are appreciated and looking back my posting seem like the ravings of a madman.
I hope you dont take it personal Mr. Bloch.
When I posted the thread I was just finished trying to figure out how I solved OOP-3 myself, in an attempt to help someone else. It then struck me that, after doing 13 assignments and reading some damm good Java books, I still dont get some very basic principles of Java.
Heck I just read finished reviewing "Core Java 2, Volume 1 Fundamentals 5e", I was singing in the rain after reading it. Heck I finally got it I thought, and wham, I try and help someone, and I cant.
As for the collections tutorial I read it. Seems like I still dont get it .
Thanks for the advice about "java.lang, java.util and (to a lesser extent) java.io!" I'll sit down and take my time to study them.
Maybe its time that I realize that to learn and understand Java (and OO) is a slow process. Like whisky the longer it matures the better.
Mr. Bloch. good luck with your book.
[This message has been edited by Johannes de Jong (edited July 10, 2001).]
Melinda Wilson
Ranch Hand

Joined: Jul 05, 2001
Posts: 35
I just want to do a reply so I may be eligible for the "Book Giveaway" to. To relate my reply to this posting. I enjoy programming in Java a whole lot more than COBOL (yes, I was a COBOL programmer once upon a time....)
Joshua Bloch
Author and "Sun God"
Ranch Hand

Joined: May 30, 2001
Posts: 124
Johannes,
> I hope you dont take it personal Mr. Bloch.
Oh that's quite all right! If I were that thin-skinned, I would never have written a book (or any public APIs, for that matter)
> Maybe its time that I realize that to learn and understand
> Java (and OO) is a slow process. Like whisky the longer it
> matures the better.
I agree with you here, on both counts. I think that anyone who promises to teach you to program in 21 days is peddling snake-oil. I've been at it for 25 years and I'm still learning. Also, I think that old whisky does taste better. The 21 year old Springbank is particularly tasty.


------------------
Joshua Bloch
Author of Effective Java
Nick Kellett
Greenhorn

Joined: May 01, 2001
Posts: 12
One thing - when you are able to explain basic Java programming including object oriented concepts to somebody, you definitely "get it". But not being able to doesn't mean you don't get it. I've had pretty good training in Java, read some great books, and have some industry experience, but I still can't really explain it to anyone. It's a complicated language, and many of the concepts can be hard to pin down. Mr Bloch, did you deliberately restrict yourself to recommending a few core libraries, or did you decide that they were the most important while writing your book?
SoonAnn Lim
Ranch Hand

Joined: Jun 21, 2001
Posts: 155
In my humble opinion, java as a language itself provides an easy tool to accomplish complicated job. Since the tools(API) are provided in addition of fundamental function, a Java programmer will have to accept the reality that the tools may not be "the" tool that behaves as he wants it to be. This is a trade off issue. Personally i am familiar with C and Java at considerably level. When writing algorithm in C, i don't have tools in hand, so i have to deal with all the fundamental issue like memory, page, segment and etc. The outcome is my program behave exactly what i want it to be. The cons is i suffer a lot more in debugging. If i develope the same algorithm in Java, i may find the class or method that suit my taste but it is a rare case. Thus i endup spending my time in searching for the tools or expanding(inherits) certain classes to accheive my goal by overwriting the methods. In short, different people have different flavor. Knowing one more language is definitely helpful to solve a problem in shorter time.
Matthew Phillips
Ranch Hand

Joined: Mar 09, 2001
Posts: 2676
I think my biggest difficulty with the Collections class, was realizing it was there. The mistake I made was dropping the 's' in my mind and checking the Collection interface. I thought that I had to implement that and then create the sort method. When I went through the Collections tutorial I finally realized that it was another class all together.
I have to agree with JdJ that the API is a bear, but I can't imagine how difficult Java would be without it.
Matthew Phillips

Matthew Phillips
Joshua Bloch
Author and "Sun God"
Ranch Hand

Joined: May 30, 2001
Posts: 124
Nick,
Hi!
> Mr Bloch, did you deliberately restrict yourself to recommending a few core libraries, or did you decide that they were the most important while writing your book?
I believe they're clearly the most important libraries; they are, in a very deep sense, fundamental to the platform. The language itself relies on classes from these packages. For example, java.lang.String is used extensively (string literals, the string concatenation operator, etc.). That's why the first edition of The Java Language Specification contained the API specs for these three libraries. They were taken out in the second edition so that the definitive library specs would reside in exactly one place. The libraries evolve faster than the language.
By the way, everyone should feel free to call me Josh instead of Mr. Bloch
Regards,

------------------
Joshua Bloch
Author of Effective Java
Sean Casey
Ranch Hand

Joined: Dec 16, 2000
Posts: 625
Josh,
This may be a basic question , but it's been bothering me since I learned Java. Why was the StringBuffer class created, and if it was to fill the need of a mutable string, then why doesn't it include all the methods of the String Class?
BJ Grau
Ranch Hand

Joined: Jul 10, 2001
Posts: 234
...ps. I finally found Sort it�s a method in the Collections class. But to my disgust I find myself unable to explain how ArrayList inherits/implements it
You have probably already figured this out, but I'll say it just to make sure you understand what's going on with
Collections.sort(List list)
sort is just a static method of the class Collections. ArrayList does not inheirit/implement it from anywhere. It is a static method so you invoke it with Collection.sort(List list) passing it a List to be sorted. In your case you pass it an ArrayList which also happens to be a List (because it is a subclass of List). It sorts your ArrayList for you.
Good luck!
BJ Grau
Ranch Hand

Joined: Jul 10, 2001
Posts: 234
Originally posted by Sean Casey:
Josh,
This may be a basic question , but it's been bothering me since I learned Java. Why was the StringBuffer class created, and if it was to fill the need of a mutable string, then why doesn't it include all the methods of the String Class?

Josh - I would imagine that it is done for performance considerations. An immutable object probably requires less overhead than a mutable one. Another reason can be seen in the case of String literals. If you have in your code:
String x = "abc";
String y = "abc";
Both x and y are references to the same object in the String pool. If Strings were mutable, changing x would also cause y to change.
Hope this helps.
Johannes de Jong
tumbleweed
Bartender

Joined: Jan 27, 2001
Posts: 5089
The 21 year old Springbank is particularly tasty.
Never heard of it, but then there are so many, nearly as many as classes in the API's , I'll keep an eye out for it thanks
Joshua Bloch
Author and "Sun God"
Ranch Hand

Joined: May 30, 2001
Posts: 124
Sean,
Whoops, almost missed your question. Sorry.
Originally posted by Sean Casey:
Josh,
This may be a basic question , but it's been bothering me since I learned Java. Why was the StringBuffer class created, and if it was to fill the need of a mutable string, then why doesn't it include all the methods of the String Class?

No, it's a fine question. To a certain extent, it's a historical accident. String and StringBuffer were written under trying circumstances under great time pressure. Over time, the two classes evolved to represent reasonably cogent abstractions. StringBuffer is good for editing character sequences, but String is the primary representation for strings, so many methods for performing interesting (non-destructive) computations on strings are present only in String, not in StringBuffer.
This is OK, as it's cheap and easy to turn a StringBuffer into a String, using the toString method. Generally speaking, you build the String up using a StringBuffer, convert it to a String using toString, and perform interesting (non-destructive) computations on the String. The cost of the conversion is a small constant, assuming you don't modify the StringBuffer after you convert it to a String. This is because the conversion is "copy-on-write": the internals are not copied unless and until you modify the StringBuffer after you've converted it into a String.
The above design philosophy dictates further evolution of String and StringBuffer. For example, the convenience method split was added to String in 1.4, but not to StringBuffer.
Note that a tiny interface called CharSequence was retrofitted to both String and StringBuffer in 1.4, so that both classes, as well as character arrays, can be used efficiently with the new regular expression facility. Arguably this should have been done a while back. CharSequence is a useful little abstraction.
Regards,

------------------
Joshua Bloch
Author of Effective Java
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
By the way, everyone should feel free to call me Josh instead of Mr. Bloch

After all if we're going to be formal, I believe "Dr. Bloch" is the correct form.
OK, I suppose I'm undermining your attempt to be informal. Everyone please disregard the previous paragraph.
For example, the convenience method split was added to String in 1.4...

A split() method? Regular expressions? What is this, Perl? No wait, it's generally readable. (Well, the rest of the language other than the regex is, but I guess it's best to bow to industry pressure in this case, rather than introducing some new syntax.)
I was annoyed that 1.4 still didn't include generics / typesafe collections, but when I saw that they did include a regex package I decided to forgive you all. It's like having a new toy to play with.


"I'm not back." - Bill Harding, Twister
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mr. Bloch - Java "conductive to quality and prductivity, and a joy to work with"
 
Similar Threads
New to Java Web Application
Finding it hard to fins something in the API ??
And the Winner's are!!
Mr. Bloch - your CV
I want to become one of the sheriff