mato (44) [Avatar] Offline
#1
Please post all errata here. Thanks.

Maria Townsley
Developmental Editor
Manning Publications Co.
boyarsky (67) [Avatar] Offline
#2
Re: Errors and Corrections
chapter 1



page 8:

The phrase "if you get a typo" sounds weird. Get it from where? The typo store? Did someone give it to you as a "gift"? Did the typo fairy stroll by? I think a more active verb would help here like "if you have a typo in the binary value"



page 8:



> So, if you've got a reason to work with binary, e.g. low-level handling of bytes, where

> you can now have bit-patterns as binary constants in switch statements, this is one

> small feature of which you may well be glad.



This sentence is hard to read. Probably because it has two ideas. But also because the end has the words ordered in an unfamilar pattern. I might say

So, if you've got a reason to work with binary, you'll be glad to have this small feature. For example, when doing low-level handling of bytes,you can now have bit-patterns as binary constants in switch statements.



<strike>page 12:

Why are you catching Throwable and not Exception? It's traditional to not catch system errors. And if there is a reason, I recommend stating it so people don't copy that code out of context. </strike>



page 15:



> Put another way – unless you're in the habit of writing code that takes as

> arguments a variable number of references of type T and does something to make a

> collection out of them, i.e. code that looks like this:

>

> code

> }

> then you can move on to the next section



The code is splicing the sentence. Can you reword it so the code is the last part of the thought? By the time I got to the "then you can move on", I had to go back and re-read the beginning of the sentence.




Message was edited by:
boyarsky
mato (44) [Avatar] Offline
#3
Re: Errors and Corrections
Thank you boyarsky! We'll certainly check the errata you noted.

The item you posted about catching throwable and exception errors on page 12 should probably be its own thread. It's more of a technical question than a typo and others might be interested in the topic.

Maria Townsley
Developmental Editor
Manning Publications Co.
boyarsky (67) [Avatar] Offline
#4
Re: Errors and Corrections
Maria,
So this thread is more for typos and blatant errors while opinions/discussion based comments should go in a new thread? Just want to confirm my understanding.
boyarsky (67) [Avatar] Offline
#5
Re: Errors and Corrections
page 3:
This is really nitpicky, but the bulletted list uses "it X" as the form for all the bullets except the last one. Why not say "It failed to support non-blocking operations" to make it more scanable/consistent? You do use the "it failed" form earlier in the list.

page 7:
"lets look at" should be "let's look at"

page 16:
I think "In Java 7 there is a whole bunch of new asynchronous channels " should be "there are". I can't explain it with a grammar rule, but it sounds wrong.

page 17:
"lets look at" should be "let's look at"


page 18:
"how this all really work behind the scenes" should be "works"

page 23:
"mean time" should be one word
mato (44) [Avatar] Offline
#6
Re: Errors and Corrections
> Maria,
> So this thread is more for typos and blatant errors
> while opinions/discussion based comments should go in
> a new thread? Just want to confirm my understanding.

Exactly! The Well-Grounded Java Developer is still in development. Books don't go through a copy editor until they enter Production when all of the writing is done. In MEAPs, you see a raw manuscript. We share MEAPs with subscribers because we want authors and subscribers to interact. It gives you a chance to affect a book by suggesting topics or commenting about the book's content.

Maria Townsley
Developmental Editor
Manning Publications Co.
karianna (2) [Avatar] Offline
#7
Re: Errors and Corrections
Hi Jeanne,

On the chapter 2 errata that you've noticed, I've fixed all of those, thanks for the great spots!

Cheers,
Martijn
martijn.verburg (86) [Avatar] Offline
#8
Re: Errors and Corrections
Again, for those that might be confused, yes that was me replying with an incorrect account.
boyarsky (67) [Avatar] Offline
#9
Re: Errors and Corrections
Chapter 3

page 1 - is Guice more common than Spring or is first due to alphabetical order? This isn't odd on it's own except that on page 3 the note lists Spring first.

page 2- You are missing an opportunity to advertise a Manning book in the footnote here smilie. ("Test Driven" or the not yet published "Art of Unit Testing" or event "JUnit in Action"

page 2 - "you could simply starting using" should be "you could simply start using"

page 2- "we'll then move onto showing you" - I think this should be "on to" in two words. "onto" is usually for climbing on something. Not 100% sure on this one though.

page 3- Martin Fowler's Inversion of Control article isn't on the main page of his site. Which is what your footnote refers to. Any reason not to use the direct link of http://martinfowler.com/articles/injection.html?

page 3 - "You're probably wondering why DI is so widely used....why it is so useful" - this is two sentences

page 6 - "using one specific AgentFinder implementations" - should be singular

page 6 - "re-factoring" does not have a dash
martijn.verburg (86) [Avatar] Offline
#10
Re: Errors and Corrections
Hi Jeanne,

Thanks for these catches - I'll be updating the Chapter with them.

Cheers,
Martijn

Message was edited by:
martijn.verburg
boyarsky (67) [Avatar] Offline
#11
Re: Errors and Corrections
Finished chapter 3.

page 9 - "light weight" is typically one word

page 16 - "lead by Bob Lee" should be "led by Bob Lee"

page 16 - "it's motivations" should be "its motivation"

page 19 - "linked bindngs is the most" should be "are"

page 22 - "in once place" should be "in one place"

page 23 - "tasteful objects" should be "stateful objects" - this one was funny!

page 23 - "Although we can't Spring in all of its entirety" is missing a word

page 24 - "There is a number of" should be "are"

page 25 - ""will continue use the existing XML based configuration" - should be "using"

page 28 - "jva7developer" is missing an "a" in the package name

page 29 - "where as" should be one word

page 30 - 'Javabean" should have a capital "B"

page 30 - "if you're following a Test Driven Development" shouldn't have the word "a"

page 31,32 and 33 - extra dashes in "re-factoring", "no-one"

page 34 - PRD vs PROD - pick one and be consistent with it. Up to this point, it is PROD. On this page, it switches.

page 35 - "you can constructor inject objects" - This reads weird. I assume you mean you can have the constructor inject?

page 35 - its' > its
z669016 (10) [Avatar] Offline
#12
Re: Errors and Corrections
In paragraph 2.2.6 Dealing with directories and directory trees, section "WALKING THE DIRECTORY TREE", you describe the FileVisitor pattern and you refer to figure 2.2. However, this figure is about "Partial class diagram of WatchService and pals" (part of paragraph 2.2.5).
shajiajf (3) [Avatar] Offline
#13
Re: Errors and Corrections
In chapter 1 page 2 A serious study of it will reward you, and it’s one of the ways a good Java programmer can start to turn (herself) into a great one. Don't say you expected only ladies program, guys do too. Is there any need to make it gender specific.
martijn.verburg (86) [Avatar] Offline
#14
Re: Errors and Corrections
Hi Jeanne,

I've been able to work through the list of issues you raised in your first post on Chapter 3. My comments below:

page 1 - I've changed the order of the NOTE: In page 3 so it matches the order here.

page 2 - We're planning on an Appendix to highlight further reading material (including several excellent Manning titles) and will reference that Appendix in the Summary of several chapters. Expect that Appendix towards the end of the MEAP.

page 2 - I've corrected the starting to start

page 2 - I've corrected the 'onto' to 'on to'

page 3 - it's been suggested as a Manning standard that you only refer to the main page of a site as underlying content tends to shift around

page 3 - I've split the phrase into two sentences

page 6 - plural taken out

page 6 - dash taken out

Thanks again for your wonderful detailed observations!
martijn.verburg (86) [Avatar] Offline
#15
Re: Errors and Corrections
Hi Jeanne,

I've caught up with these items as well, my comments below:

page 9 - fixed

page 16 - lead vs led fixed

page 16 - Sentence changed to avoid this

page 19 - fixed

page 22 - smilie, fixed.

page 23 - added 'cover'

page 24 - fixed

page 25 - fixed

page 28 - fixed

page 29 - fixed

page 30 - JavaBean fixed

page 30 - altered sentence to make this go away

page 31-33 - fixed

page 34 - standardised on PROD

page 35 - clarified English here

page 35 - its fixed

Thanks again for picking all of these up!
martijn.verburg (86) [Avatar] Offline
#16
Re: Errors and Corrections
Hi z669016!

Thanks for your great catch! This has been rectified.

Cheers,
Martijn
martijn.verburg (86) [Avatar] Offline
#17
Re: Errors and Corrections
Hi shajiajf,

This is an interesting topic! Both Ben and I are currently involved in some really interesting discussions with the LJC (London JUG) around diversity in the world of Java programming. We deliberately put 'herself' in the Chapter as a subtle nod to promoting women in Java programming. We both feel that the ratio of women to men is too low (which is something we'd like to see evened out over time).

I'd like to continue this in another thread (Diversity in the book) as both Ben and I are open to thoughts on this topic. Clearly it can work the other way as well as you pointed out.

Cheers,
Martijn
AlanM (1) [Avatar] Offline
#18
Re: Errors and Corrections
Chapter 1 (http://www.manning.com/evans/TWGJD_free_CH01.pdf)

Page 1
“One of its’ most important and noticeable features” s/b “One of its most important and noticeable features”

Page 4
'this point is - “what constitutes a small change to the spec”?' s/b 'this point is - “what constitutes a small change to the spec?”.'

Page 8
In Listings 1.1 and 1.2 why does the parameter name, fileName_, end in an underscore? This does not follow typical Java variable naming convention (e.g. http://download.oracle.com/javase/tutorial/java/nutsandbolts/variables.html).

Page 9
“The problem comes that in previous versions of Java, code like this:” sounds awkward.

“to use the next Java 7 syntax” would read better as “to use the Java 7 syntax”

“even the reference howto from Sun were wrong.” s/b “even the reference howto from Sun was wrong.”
areese78 (10) [Avatar] Offline
#19
Re: Errors and Corrections
MEAP Edition
Manning Early Access Program
The Well-Grounded Java Developer version 2

Chapter 2, page 18.

Now that you've seen a brief example of the core interactions between FileSystem, FileStore and
Path, we'll move on to some real world use cases, starting with basic copy and
move operations.


Starting at the ',' after Path the font is wrong, the fixed width is bleeding past the end of Path. I've italicized everything in the paragraph that is fixed width.
martijn.verburg (86) [Avatar] Offline
#20
Re: Errors and Corrections
Thanks! I've fixed that in my working copy.
areese78 (10) [Avatar] Offline
#21
Re: Errors and Corrections
One more, same thing. smilie

Providing the startingDir is easy enough, but in order to provide an implementation of the
FileVisitor interface (e.g. Provide the tricky looking FileVisitor<? super Path> visitor
parameter) it gets a bit trickier as you
need to implement at least five methods:

Also a side note on that same paragraph, you might add a note that T is a subclass of Path. For me it's readily apparent, but I'm not sure about others.
martijn.verburg (86) [Avatar] Offline
#22
Re: Errors and Corrections
Thanks again, I've also amended those!
areese78 (10) [Avatar] Offline
#23
Re: Errors and Corrections
2 errors around page 34/35

Another font bleed:

Page 34:
You can already see how clean the
emailFriendlyAgents(..) method has become #3.

Should be:
emailFriendlyAgents(..) method has become #3.


Page 34/35 Listing 3.5:
#C is missing from the references at the bottom.

I can tell it's referencing something about how emailFriendlyAgents isn't concerned with the implementation, but I'm not sure what text would logically fit here.

Listing 3.5:

public class HollywoodService
{
private AgentFinder finder = null;
@Inject #A
public HollywoodService(AgentFinder finder) #B
{
this.finder = finder;
}
public void emailFriendlyAgents() #C
{
List<Agent> agents = this.finder.findAllAgents();
List<Agent> friendlyAgents =
filterAgents(agents, "Java Developers");
EmailService.emailAgents(friendlyAgents);
}
public static List<Agent> filterAgents(List<Agent> agents,
String agentType)
{
..
}
}
#A JSR-330 @Inject annotation
#B AgentFinder is injected
areese78 (10) [Avatar] Offline
#24
Re: Errors and Corrections
Figure 3.1 on page 38 section 3.2.3 is really hard to read.

I looked back and Figure 2.3 isn't nearly as light as Figure 3.1 is.
martijn.verburg (86) [Avatar] Offline
#25
Re: Errors and Corrections
Fixed these, thanks!
martijn.verburg (86) [Avatar] Offline
#26
Re: Errors and Corrections
You're quite right about the image, it's actually a global problem we've discovered and our graphic designer is working on a global update of all imagery. It will get fixed, but it will be further into the MEAP when you see the darker images come through.
Andy.Newton (1) [Avatar] Offline
#27
Re: Errors and Corrections
This is not an error or correction, but as I don't see a thread for suggestions:

Chapter 1 (http://www.manning.com/evans/TWGJD_free_CH01.pdf)
(No I haven't paid yet smilie

1.3.6, re: "you can't make arrays of a specified generic type"

Suggestion: a foot note or call out explaining why not.

Cheers.
juergenhoetzel (25) [Avatar] Offline
#28
Re: Errors and Corrections
page11:

Invalid lookup tables of type List<String, String>, should be:


Map<Integer, Map><String,String>> userlist = new HashMap<>();
deisner (5) [Avatar] Offline
#29
Re: Errors and Corrections
Chapter 1, page 1:

"It’s perhaps a bit surprising that there quite a few Java programmers" =~ s/there quite/there are quite/
benjamin.evans (18) [Avatar] Offline
#30
Re: Errors and Corrections
Hi,

Which chapter is this from? - I can't find it in Chapter 1
avysk (14) [Avatar] Offline
#31
Re: Errors and Corrections
In 1.3.2 "Enhanced Syntax for Numeric Literals", subsection "SHORT AND BYTE LITERALS" is written:

-------
This is, of course, exactly the sort of small change that Project Coin was invented for, and so in Java 7 you can write:

byte allOnes = 255y;
short myShort = 64000s;
System.out.println(“allOnes = ”+ allOnes);
-------

Ok, let's try:

$ javac Test.java
Test.java:6: error: ';' expected
byte allOnes = 255y;
^
1 error

(forum kills formatting, but in the original error message ^ points at 'y')

$ javac -version
javac 1.7.0-ea

I'm using jdk-7-ea-bin-b137-linux-x64-07_apr_2011.tar.gz binary build.
avysk (14) [Avatar] Offline
#32
Re: Errors and Corrections
...ah, and also that listing is using “ and ” instead of ".
benjamin.evans (18) [Avatar] Offline
#33
Re: Errors and Corrections
Good catch - these have actually been deferred to Java 8.

Will update the chapter on the next revision - thanks.
avysk (14) [Avatar] Offline
#34
Re: Errors and Corrections
Hello,

some comments about Chapter 2:

2.1.2, pg.15: "plug-gable" -> "pluggable"

2.1.1, pg.16: "data-grams" -> "datagrams"

2.1.1, pg.18, last sentence -- the text should not be in monotype after "Path".

2.2.3, pg.18-19, figure 2.1, listing 2.2 -- the text says about home directory of user karianna on Mac OS X, which normally will be /Users/karianna. Nevertheless, in the listing one can see something strange: "/user/karianna".

2.2.3, pg. 19, last sentence before the listing -- should it really ends with text in monotype?

2.2.3, pg. 19, footnote: POSIX is not a standard but a family of standards.

2.2.3, listing 2.2 -- maybe it would make sense to mention that this program will not work for everyone since not everyone can change file permissions. Well, it would work for the user owning the file -- maybe it's better to mention this explicitly.

2.2.3, listing 2.2 -- perms are printed first time after they are cleared, is it intentional? I'd say you want to print them out between #2 and #3 in the code.

2.2.4, listing 2.3 -- just a question: what would happen if "/opt/platform/java" is a symlink to another symlink which points to perfectly valid directory? Maybe it's just me but the whole explanation is unclear; what exactly happens in #3 lines?

2.2.5, listing 2.4 -- pathname "/usr/karianna" is strange (and normally is not "home directory of the user karianna", as the text above the listing states).

2.2.5, listing 2.4 -- #3 probably should be on the previous line, if (event.kind() ==...

2.2.6, pg. 21, last line: "walkFileTree method" -- should "method" be in monotype?

2.2.6, pg. 22, first line: "Deal with large directory structures" -- what's exactly "large" directory structure? How it's different from "small"? A couple of words about it would be helpful.

2.2.6, pg.22, footnote: was "ww." in the site address intentional or should it be "www."?

2.2.6, listing 2.4 -- we had one listing 2.4 already, this one should be 2.5

2.2.6, listing 2.4: line #2 uses wildcard. Would be nice to mention how they work. What just "*" would match? Everything like in Unix? Files with no extension like in DOS? Or is it platform-dependent?

2.2.6, pg.22, after "Walking the directory tree" heading: "it gets a bit trickier as you" should not be in monotype

2.2.6, pg.22, last line: I'm not sure but don't you need a comma in "Looks like a good deal of work right?"

2.2.6, pg.22, last line: "Pictorially it's little easier to understand as Figure 2.2 demonstrates" -- (1) what "it" is easier to understand? (2) what fig. 2.2 demonstrates? Does it demonstrate that something is easier to understand? Disclaimer: English is not my mothertongue so maybe it's perfectly normal sentence.

2.2.6, listing 2.5 -- if the previous 2.4 becomes 2.5, it would be a good idea to change the number here as well...

2.2.6, listing 2.5 -- it's horrible to break it in a such manner between pages.

2.2.6, listing 2.5 -- why you need to mix #1, #2 and #3 with #A?

2.2.6, listing 2.5 -- comment about #1 is wrong, this line does not call walkTheTree, it calls walkFileTree.

2.2.6, listing 2.5 -- all comment about listing (#A, #1, #2 and #3) looks like a typical example of how one should not comment the code: a = a + 2 // increments a by 2

2.2.7, first sentence -- should "interface" be in monotype?

2.2.7, unnumbered code listing -- why is duplicated after c: ?

2.3, pg.24 "to take advantage of the latest hardware and software advances" plus footnote "...and Operating System socket and file handling support". What!? Do you mean sockets and file handling are "latest software advances"? And why "Operating System" not "operating system"?

2.3, pg.25, fourth bullet: the end of the sentence should not be in monotype

2.3, pg.25, "We'll begin by getting you to try out..." Well, again -- English is not my mothertongue but to my ear this sounds horrible.

2.3.1, pg.25, "to read 100,000 bytes form a file (a slow operation)". Huh? Are you using punchcards? (Given that the listing below does Thread.sleep(500) in a cycle to wait for reading of 100 Kb to finish, you are.)

2.3.1, listing 2.6 (you do remember by now it should be 2.7, right?) -- again that strange path "/usr/karianna".

2.3.1, listing 2.6 -- to have pagebreak just before } is not nice.

2.3.2, listing 2.7 (should be 2.smilie -- "/usr/karianna" again

2.3.2, listing 2.7 -- why now #A, #B, ... instead of #1, #2 etc used previously?

2.4.1, listing 2.8 (should be 2.9) -- #As again

2.4.2, pg.29 "multi-cast" -> "multicast"

2.4.2, listing 2.9 (should be 2.10) -- #As again

2.4.2, listing 2.9 -- indentation is wrong in #A and #B lines (not exactly *wrong* but inconsistent with previous listings, the line continuation after = is not indented)

2.4.2, listing 2.9 -- #D -- maybe it makes sense to explain why you're using .getByName() with IP address (I know smilie ). Or to use host name instead of IP address, to prevent unneeded confusion.

2.5, pg.29: "I/O performance is significantly improved with the new asynchronous I/O support". How come? I/O performance per se should be worse with asynchronous approach, due to the overhead (not talking about having multiple threads reading/writing simultaneously from/to the same file). Something else is improved, but not I/O performance as such, right? If I'm not right, it would be nice to explain why I/O performance really improved.
martijn.verburg (86) [Avatar] Offline
#35
Re: Errors and Corrections
Hi there,

Thanks for your detailed review of chapter 2!!

I'll certainly be fixing some of the errors you found! This sort of feedback is very valuable to us.

Unfortunately there are also several errors which won't be fixed per say, but instead replaced with new material. Why? Because a large chunk of Chapter 2 has been superseded by recent changes to NIO2 in the latest Java 7 builds!

I hope to have a revised chapter ready in May.

Thanks again for your help!

Cheers,
Martijn
juergenhoetzel (25) [Avatar] Offline
#36
Re: Errors and Corrections
It's on Page 11 (Diamond Syntax):

Map<Integer, List><String, String>> usersLists = new HashMap<Integer, List><String, >
String>>();

results in error: "wrong number of type arguments" for list type. Should be:

Map<Integer, Map><String,String>> ....
sandman202 (4) [Avatar] Offline
#37
Re: Errors and Corrections
In the section titled "Linked Bindings". The first sentence starts off with, "Linked bindings is" should be "Linked bindings are".
mato (44) [Avatar] Offline
#38
Re: Errors and Corrections
Thanks sandman202!

Maria Townsley
Development Editor
Manning Publications Co.
globulon (18) [Avatar] Offline
#39
Re: Errors and Corrections
Section 3.3.3

public class AgentFinderProvider extends Provider<AgentFinder>

it seems to me that it is

public class AgentFinderProvider implements Provider<AgentFinder>

But maybe I missed something

Regards

Message was edited by:
globulon
martijn.verburg (86) [Avatar] Offline
#40
Re: Errors and Corrections
Thanks for mentioning this! I'll double check the code sample.
craigpark (1) [Avatar] Offline
#41
Re: Errors and Corrections
In table 5.2, your types have a mixture of uppercase and lowercase letters at the start. Since these should be primitives (apart from references and arrays), you need lowercase.

For clarity, it might be worth saying explicitly in the test that these are primitive types.

Also, if you are looking for an example of usage here, I most recently came across this in GWT's JSNI which mimics JNI.
martijn.verburg (86) [Avatar] Offline
#42
Re: Errors and Corrections
Thanks for picking up on that, we'll be sure to correct it for the next version of the chapter
globulon (18) [Avatar] Offline
#43
Re: Errors and Corrections
Hi

I am preparing a little blog entry about Method handle and I came naturally to read chapter 5. Fabulous, a lot of answers to my questions =D
I found in section 5.2:

MethodHandle mh = manager.makeMh();
try {
System.out.println("With Method Handle");
mh.invokeExact(hndl); #B
} catch (Throwable e) { #C
e.printStackTrace();
}

In b142 of JDK7 I have to specify as first argument the receiver with invokeExact using my sample.
It seems to be

mh.invokeExact(manager, hndl)
martijn.verburg (86) [Avatar] Offline
#44
Re: Errors and Corrections
Hi there!

Thanks for the catch! There's a few small API changes like that in the latest builds, we'll have to do a careful sweep of the source code towards the end of writing smilie
martijn.verburg (86) [Avatar] Offline
#45
Re: Errors and Corrections
Hi AlanM,

I'm not sure we responded to you earlier - but we've corrected the various issues you mention.

Cheers,
Martijn
dimitrisli (2) [Avatar] Offline
#46
Re: Errors and Corrections
Page 3:

last phrase of the "Is Java a compiled of interpreted language?" box doesn't really make sense:

So perhaps the real answer to “Is Java compiled or
interpreted?” is actually “Yes.”
martijn.verburg (86) [Avatar] Offline
#47
Re: Errors and Corrections
This is an old form of humour - a play on words if you will. Basically it means that it's both. We'll probably change the language as it is a little obscure smilie
gcohoon (2) [Avatar] Offline
#48
Re: Errors and Corrections
(v5 of MEAP)

2.2.3 - page 27
"as well as other importas not shown" -- imports

2.2.3, Listing 2.2 - pages 26-27
The following line of code is repeated: posixPermissions.add(USER_READ); At first I thought the second one might want to be GROUP_WRITE, but that contradicts the goal of "only karianna can write to it." So now I think the second one is completely unnecessary.

2.3 - page 34
"For asynchronous datagram oriented operations (e.g. UDP)" after AsynchronousDatagramChannel continues in code font.
gcohoon (2) [Avatar] Offline
#49
Re: Errors and Corrections
MEAP v5

3.1 - page 42
You could simply starting using the various DI frameworks -- start or begin starting
sdavi1010 (1) [Avatar] Offline
#50
Re: Errors and Corrections
(pg. 146 (section 6.1.2)

I believe in the third bullet, you mean to say something to the effect of:

"SSD - 0.1 ms or less to access the disk, but **less** expensive compared to hard disk"
pwoodward (1) [Avatar] Offline
#51
Re: Errors and Corrections
(pg 39 (section 2.4.1))

AsynchronousDatagramChannel has been removed from final API.

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6993126
adrianmurray (4) [Avatar] Offline
#52
Re: Errors and Corrections
MEAP V5

3.4 Page 63

"Although we can't Spring in all of its entirety" should be something like "Although we can't cover Spring in all of its entirety"

3.4.2 Page 64

"Spring tries not reinvent the wheel" should be "Spring tries not to reinvent the wheel"

Regards,
Adrian
juergenhoetzel (25) [Avatar] Offline
#53
Re: Errors and Corrections
- You use the term "form" multiple times, in context of normal functions. This gives the impression that they are (special) "forms":
- Page 293: The form (nth) -> The function (nth)
- Page 294: Clojure has a map (form) -> Clojure has a map (function)
- Page 295: Clojure forms are in many cases variadic -> Clojure functions ...

- Page 294: Because you previously introduced keywords as function, the example can be simplified:
user> (map :name authors)

- Page 295: This and the other examples use a non-common style of closing parentheses, See: http://blog.fogus.me/2010/08/30/community-standards/

The example can be simplified by removing the
let-form. Also like in clojure.core and other clojure code Iprefer to use "coll" for
collections:
(defn list-maker-fun [coll f]
(map (fn [z] (list z (f z))) coll))

- Page 297: Can be simplified. Also use "coll" as Collection identifier and fixed
formatting:
(defn schwarz [coll key-fn]
(map first
(sort-by second
(map (fn [x] (list x (key-fn x))) coll))))

- Page 300: deref does not take a var object, it takes a ref and returns the
in-transaction-value of the ref.

- Page 300: Simplefied Schwatzian Transform, using anonymous function literal:
(defn schwarz [coll key-fn]
(map first
(sort-by second
(map #(list % (key-fn %)) coll))))

- Page 304:
"conj: Returns a new collection with the element added to the end" is not correct.
Where it is added depends on the concrete type:
user> (conj [1] 2)
[1 2]
user> (conj '(1) 2)
(2 1)
user>

- Page 313:
Example can be simplified without let:
(defn wait-with-for [limit]
(loop [ctr 1]
(Thread/sleep 500)
...

- Page 316 The Account Example mixes pure functional code and STM code.

Also there is an subtle error in the multithreaded/STM example:
The balance value is de-ref-ed outside of a transaction to check if it is positive.
Before doing the deposit inside the dosync block another Thread could have
changed the ref value.

For "Readability Reasons" and "Code Reusage" all account functions should be
pure functional.
See my Gist: https://gist.github.com/2586256
lmurray (3) [Avatar] Offline
#54
Re: Errors and Corrections
MEAP v7, page 147, Table 5.4 - Second item (ldc) Description says:

Loads a constant form the pool onto the stack. Has
type-specific and wide variants.

Should probably be "from" not "form".

Loads a constant from the pool onto the stack. Has
type-specific and wide variants.
JeffD (2) [Avatar] Offline
#55
Re: Errors and Corrections
Page 132

This also
gives the developer a simple way to ensure as much as type safety as possible.

Extra "as" in sentance.
JeffD (2) [Avatar] Offline
#56
Re: Errors and Corrections
Page 147

Loads a constant form the pool onto the stack. Has
type-specific and wide variants.

Should read:

Loads a constant from the pool onto the stack. Has
type-specific and wide variants.
martijn.verburg (86) [Avatar] Offline
#57
Re: Errors and Corrections
Hi all,

Apologies for the radio silence and thanks for the valuable feedback. These have all been corrected.

Cheers,
Martijn
benjamin.evans (18) [Avatar] Offline
#58
Re: Errors and Corrections
Hi Juergen,

Thanks for the time taken to give such detailed feedback, and sorry for the delay in responding to you. At some point in the past, the author forum stopped mailing me notifications, so I wasn't aware of new threads which needed my attention.

I'm going to put in quite a few of your suggestions, but not all of them. The book's aimed at primarily Java programmers, so there are some places where I'm trying to make things easier for the "tourists" - by doing things in a way which is slightly unusual for experienced Clojure programmers.

In particular, some of the additional, unnecessary (let) constructions are to make it easier to see the scoping & the same is true for the slightly odd closing parens in places.

Finally, thanks for the bug fixes. Some of these managed to slip by both of our tech reviewers.

Hope you enjoy the finished result!

Ben
nicola.cammillini (1) [Avatar] Offline
#59
Minor typo
page 8:

"The full set of actions that that must be performed..."

Maybe "The full set of actions that must be performed..."?

Best regards,
NC
martijn.verburg (86) [Avatar] Offline
#60
Re: Minor typo
Hi Nicola,

Thanks for the catch! We'll add that to the errata (assuming this was the full e-book you spotted this in?).

Cheers,
Martijn
arnaud88 (1) [Avatar] Offline
#61
Re: Errors and Corrections
Hi

Don't know if someone has already noticed this:

p105, Listing 4.12:
the synchronization does not seem correct.
The public method shutdown() is synchronized to change change the 'shutdown' field (good),
but the loop in run() directly read the field without synchronization.

So the Thread that runs the loop could ignore 'shutdown' flag changes from another thread.

Thanks for this very interesting (and unique) book!

Arnaud
martijn.verburg (86) [Avatar] Offline
#62
Re: Errors and Corrections
Thanks Arnaud, we'll investigate and update the Errata as appropriate, glad you're enjoying the book!
drapostolos (3) [Avatar] Offline
#63
Re: Errors and Corrections
In chapter 3.2.2 page 64/65. The code example declares an enum in all upper-case letters.
public enum GENRE {CLASSICAL, METAL, ROCK, TRANCE}
Shouldn't enums be declared with first letter as uper-case, with next letters in lower-case (to follow java standards), i.e. Genre?

Additionally, the enum seems to be referred with lower-case:
- Figure 3.1 (side 64), as "Genre.METAL" and "Genre.CLASSICAL"
- in the example "Genre genre() default Genre.TRANCE"

Further more, the example is not compiling for me (even when all GENRE has been changed to Genre) smilie
But maybe it is just me not having experience with annotations.
drapostolos (3) [Avatar] Offline
#64
Re: Errors and Corrections
In Listing 3.2 (page 57), the input argument "agentType" in the bellow method, is never used, instead the string "Java Developer" duplicated.

private static List<Agent> filterAgents(List<Agent> agents, String agentType) {
List<Agent> filteredAgents = new ArrayList<>();
for (Agent agent : agents) {
if(agent.getType().equals("Java Developer")){
filteredAgents.add(agent);
}
}
return filteredAgents;
}


/Alex
martijn.verburg (86) [Avatar] Offline
#65
Re: Errors and Corrections
You're right it should be Genre as opposed to GENRE, we'll get that corrected in the errata. What compile error are you getting? Is this when you run the Maven build?
martijn.verburg (86) [Avatar] Offline
#66
Re: Errors and Corrections
Thanks we'll get tha tin the errata!
drapostolos (3) [Avatar] Offline
#67
Re: Errors and Corrections
I have defined the two classes below in the same package. The MetalRecordAlbum does not compile (using Eclipse). Eclipse complains about the following row:
@Inject @MusicGenre(Genre.METAL) Genre genre;
more specifically: "Genre.METAL"

with the following error message:
Description Resource Path Location Type
The attribute value is undefined for the annotation type MusicGenre MetalRecordAlbum.java /well-grounded/src/main/java/well/grounded/qualifier line 9 Java Problem


Maybe it should be like this?
@Inject @MusicGenre(genre=Genre.METAL) Genre genre;






=======================================
package well.grounded.qualifier;

import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;

import javax.inject.Qualifier;

@Documented
@Retention(RUNTIME)
@Qualifier
public @interface MusicGenre {

Genre genre() default Genre.TRANCE;

public enum Genre {CLASSICAL, METAL, ROCK, TRANCE}

}

=======================================
package well.grounded.qualifier;

import well.grounded.qualifier.MusicGenre.Genre;

import com.google.inject.Inject;

public class MetalRecordAlbum {

@Inject @MusicGenre(Genre.METAL) Genre genre;

}
martijn.verburg (86) [Avatar] Offline
#68
Re: Errors and Corrections
Seems about right, I'll test that here locally and make the appropriate changes, thanks again, it's most appreciated!
arkangelofkaos (1) [Avatar] Offline
#69
Re: Errors and Corrections
Not sure if this has been found already but:

Typo on P.234 in the XML box. The footer reference should read 10 instead of 9.
martijn.verburg (86) [Avatar] Offline
#70
Re: Errors and Corrections
Thanks we'll collect that up - M
Sven73 (1) [Avatar] Offline
#71
Re: Errors and Corrections
The same error that Arnaud reported for Listing 4.12 can also be found in 4.13 pg. 106: writing to shutdown is synchronized but reading is not.

By the way, is there somewhere a consolidated errata list?
martijn.verburg (86) [Avatar] Offline
#72
Re: Errors and Corrections
Hi there,

We've sent in the errata to Manning who should be hosting it shortly. Ben is still looking at the two concurrency cases, so they might come in a little later.
S11001001 (7) [Avatar] Offline
#73
Re: Errors and Corrections
(p67, listing 3.6)

> import com.google.inject.Inject;
> import com.google.inject.Provider;

Should be from javax.inject instead?
martijn.verburg (86) [Avatar] Offline
#74
Re: Errors and Corrections
That's correct, the javax.inject imports are 330 compatible.
S11001001 (7) [Avatar] Offline
#75
Re: Errors and Corrections
Thanks martijn.verburg.

§4.2.2, p84:

> This can be because the program code indicates that the thread
> should pause before continuing (via Thread.sleep()) or because the
> thread must wait until notified (usually that some external
> condition has been met). Under these circumstances, the thread is
> removed from the core and releases all its locks.

I was surprised to read "releases all its locks", so I tried this out, but was unable to reproduce this behavior. Is some other meaning of "lock" than the one I'm assuming the intended one?

$ java -version
java version "1.7.0_25"
OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1ubuntu0.13.04.2)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

Code sample at: https://bazaar.launchpad.net/~scompall/+junk/sbt-project--wgjd/view/head:/src/main/java/com/nocandysw/Locks.java

which prints what I expected:

About to sleep one
Starting two
<waiting....>

Likewise, the annotation of the `Thread.sleep()' call in Listing 4.6, p95:

> If not done, release lock and wait

Rather, the lock seems to have been not acquired at all in this block.
Tim_ (1) [Avatar] Offline
#76
Re: Errors and Corrections
SRP The Single Responsibility Principle
A class should have one, and only one, reason to change.
http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod


Table 11.2 Principles of SOLID object-oriented code
Single responsibility principle (SRP)
Each object should do one thing, and one thing only.

Which description is correct?
domulys (1) [Avatar] Offline
#77
HollywoodServiceJSR330
For Listing 3.5 on page 60, the function has return type 'void', but it returns a list. It is also not static, whereas it was static in Listing 3.4.

It's also not too clear what all has changed here, except for the @Inject keyword. It's not obvious to me how @Inject made my life easier, but I'm still reading the chapter, and maybe it will be explained later.
Chad Philip Johnson (1) [Avatar] Offline
#78
Little late to the party here, and the book's errata doesn't seem to have most of these corrections, but I figured it would be better to share than not.

Chapter 04: Modern Concurrency, pages 100 and 101

In listing 4.10 on page 100, the second instance of MicroBlogTimeline is assigned to an incorrectly named variable (tl22 instead of tl2, as it is used later in the code):
final MicroBlogTimeline tl1 = new MicroBlogTimeline("TL1", l, lock);
final MicroBlogTimeline tl22 = new MicroBlogTimeline("TL2", l, lock);

Page 101 has two related errors:
01) The variable names mbex1 and mbex2 are used instead of tl1 and tl2, respectively.
02) The text states that "the Iterator contained in mbex1 was copied by mbex2" which is incorrect. A new Iterator is created for the second instance of MicroBlogTimeline following the addition of a new element to the CopyOnWriteArrayList; this new Iterator is associated with the newly created underlying array.
395882 (1) [Avatar] Offline
#79
any plan for second edition to use java 8?
434214 (1) [Avatar] Offline
#80
There is a very disappointing and severely false statement, given by the following snippets from the text in Chapter 4 "Modern concurrency":

1. Page 84, Section 4.2.2 titled "The state model for a thread"
This can be because the program code indicates that the thread should pause before continuing (via Thread.sleep()) or because the thread must wait until notified (usually that some external condition has been met). Under these circumstances, the thread is removed from the core and releases all its locks.



2. Pages 94, 95, 96, Section 4.3.2 titled "Locks—java.util.concurrent.locks" makes the same mistake, reinforcing the totally wrong and danger piece of learning:

This is an attempt to remove the deadlock by giving other threads a chance to get at the lock.


The real solution is to ensure that if the attempt to get the second lock fails, the thread should release the lock it’s holding and wait briefly, as shown in the next listing. This gives the other threads a chance to get a complete set of the locks needed to progress.


In this version, you examine the return code of tryConfirmUpdate(). If it returns false, the original lock will be released. The thread will pause briefly, allowing the other thread to potentially acquire its lock.


As seen from the referred listing, the change introduced is a call to the Thread.sleep() static method (lines 16-18 below):

public void propagateUpdate(Update upd_, MicroBlogNode backup_) {
	boolean acquired = false;
	boolean done = false;
	while (!done) {
		int wait = (int)(Math.random() * 10);
		try {
			acquired = lock.tryLock(wait, TimeUnit.MILLISECONDS);
			if (acquired) {
				System.out.println(ident +": recvd: " + upd_.getUpdateText() +" ; backup: "+backup_.getIdent());
				done = backupNode_.tryConfirmUpdate(this, update_);
			}
		} catch (InterruptedException e) {
		} finally {
			if (acquired) lock.unlock();
		}
		if (!done) try {
			Thread.sleep(wait);
		} catch (InterruptedException e) { }
	}
}




To the contrary, official JavaDoc of the Thread.sleep method explicitly states that the sleeping thread does not give up ownership of any locks/monitors that it had acquired prior to sleeping:

https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html#sleep(long)

The thread does not lose ownership of any monitors.



This is a very serious mistake, that seriously impacts the usefulness and professionalism of this reading.