The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

biospringxyz (89) [Avatar] Offline
#101
Re: Errors and Corrections
In chapter 9, the listing number is not sequential:

Listing 9.12
(Listing 9.13 missing)
(Listing 9.14 missing)
Listing 9.15
biospringxyz (89) [Avatar] Offline
#102
Re: Errors and Corrections
@Main annotation doesn't work in Listing 9.23. It produces this error message at the groovyConsole:

"unable to resolve class Main , unable to find class for annotation"
biospringxyz (89) [Avatar] Offline
#103
Re: Errors and Corrections
Sorry about reporting the problem with the @Main annotation. I didn't realize the following sections explain how to make the @Main annotation work... smilie

Hoon
bodiam (27) [Avatar] Offline
#104
Re: Errors and Corrections
Hi Hoon,

Thank you so much for your feedback. I've incorporated all of them, and I've also added an explanatory text about the @Main annotation. So both chapter 8 and 9 have now been updated with your changes. Thanks again,

Erik
biospringxyz (89) [Avatar] Offline
#105
Re: Errors and Corrections
Listing 12.1 is titled: "Table 12.1 Usage of dump and inspect"

Should "Table 12.1" read "Listing 12.1"?
biospringxyz (89) [Avatar] Offline
#106
Re: Errors and Corrections
Listing 12.1, the 2nd assert doesn't work due to a different output from the dump() method:

assert newline.dump() ==
'''<java.lang.String@a value=[ >
] offset=0 count=1 hash=10>'''

When run, the error msg is displayed:

assert newline.dump() == '''<java.lang.String@a value=[ ] offset=0 count=1 hash=10>'''
| | |
| | false
| <java.lang.String@a value= <br /> | hash=10 hash32=0>

Hoon
biospringxyz (89) [Avatar] Offline
#107
Re: Errors and Corrections
Listing 12.1, the 3rd assert doesn't work:

assert newline.inspect() == /"
"/

When run, the following error msg is displayed:

assert newline.inspect() == /"
"/
| | |
| '
' false

The inspect() method seems to return the character type instead of the string type.

Hoon
bodiam (27) [Avatar] Offline
#108
Re: Errors and Corrections
And again, also fixed smilie You've got a sharp eye! Nice, thanks!
biospringxyz (89) [Avatar] Offline
#109
Re: Errors and Corrections
Listing 12.2, 1st and 2nd assert fail to compile due to the use of back quotes in front of the property names:

assert obj.hasProperty(`first')
assert obj.respondsTo(`myMethod')

Also,

the 3rd assert fails due to the difference between the output from the keySet() method and the HashSet(keys):

assert obj.properties.keySet() == new HashSet(keys)
| | | | | |
| | | | | [first, second, third, class, metaClass]
| | | | [metaClass, second, class, third, first]
| | | false
| | [class, first, second]
| [class:class com.demo.MyClassx, first:1, second:2]
com.demo.MyClassx@63d6a00c

Hoon
bodiam (27) [Avatar] Offline
#110
Re: Errors and Corrections
Fixed!
biospringxyz (89) [Avatar] Offline
#111
Re: Errors and Corrections
2nd bullet in the paragraph (before the class StringCasingCategory definition) that starts with:

"When working through the Formatter API documentation, ...."

It says, "Placeholders can be prefixed with n$ to map the placeholder to the nth argument in the list."

The "n$" notation seemed odd so I tried:

printf('Math.E = 2$%2.5f, Math.PI = 1$%2.5f', Math.PI, Math.E )

which resulted in:

Math.E = 2$3.14159, Math.PI = 1$2.71828

I tried also:

printf('Math.E = $2%2.5f, Math.PI = $1%2.5f', Math.PI, Math.E )

which displayed:

Math.E = $23.14159, Math.PI = $12.71828

So, neither "n$" nor "$n" didn't seem to be paired with the right argument. Can this be further clarified?
biospringxyz (89) [Avatar] Offline
#112
Re: Errors and Corrections
Listing 12.3 is titled, "Table 12.3 File's object iteration..."

Should "Table" read "Listing"?
Corvin (7) [Avatar] Offline
#113
Re: Errors and Corrections
MEAP v. 15 Page listing 14.2

assert info(plan) == 'element: plan'
assert plan.childNodes.length == 5

why 5? it should be described

and small typo on page 356: "It returns a t ree of " I hope that the author means "It returns a tree of"
paulk_asert (33) [Avatar] Offline
#114
Re: Errors and Corrections
For your example you want:

printf('Math.E = %2$2.5f, Math.PI = %1$2.5f', Math.PI, Math.E )

See the javadoc for java.util.Formatter for more details.
Corvin (7) [Avatar] Offline
#115
Re: Errors and Corrections
MEAP v. 15 Page listing 14.2

assert info(plan) == 'element: plan'
assert plan.childNodes.length == 5

why 5? it should be described

and small typo on page 356: "It returns a t ree of " I hope that the author means "It returns a tree of"
Corvin (7) [Avatar] Offline
#116
Re: Errors and Corrections
MEAP 1 page 356

Dealing with child nodes and attributes as in 0 doesn’t feel groovy either.


page 360:

If we wrote the XmlSlurper version of 0 it
biospringxyz (89) [Avatar] Offline
#117
Re: Errors and Corrections
Listing 12.6, Last assert:

example.withInputStream { is ->
assert 'line one' == is.readLine()
}

produces the following error message:

Caught: groovy.lang.MissingMethodException: No signature of method: java.io.BufferedInputStream.readLine() is applicable for argument types: () values: []
Possible solutions: readLines(), readLines(java.lang.String), eachLine(groovy.lang.Closure), eachLine(java.lang.String, groovy.lang.Closure), eachLine(int, groovy.lang.Closure), eachLine(java.lang.String, int, groovy.lang.Closure)
groovy.lang.MissingMethodException: No signature of method: java.io.BufferedInputStream.readLine() is applicable for argument types: () values: []
Possible solutions: readLines(), readLines(java.lang.String), eachLine(groovy.lang.Closure), eachLine(java.lang.String, groovy.lang.Closure), eachLine(int, groovy.lang.Closure), eachLine(java.lang.String, int, groovy.lang.Closure)
at com.demo.Listing_12_6_FileReadingExamples$_run_closure5.doCall(Listing_12_6_FileReadingExamples.groovy:55)
at com.demo.Listing_12_6_FileReadingExamples.run(Listing_12_6_FileReadingExamples.groovy:54)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

Hoon
biospringxyz (89) [Avatar] Offline
#118
Re: Errors and Corrections
Thanks!
biospringxyz (89) [Avatar] Offline
#119
Re: Errors and Corrections
Listing 12.8:

1. Timezone issue. If the System's timezone doesn't default to CET, the assert will fail. Should a line setting the timezone be added before using "new Date()" as in:

System.setProperty('user.timezone', 'CET')
writer << new Date(0) << "
"

2. Should the map value for the assert statement be expressed:

[a:1, b:2]

rather than

["a":1, "b":2]


Hoon
biospringxyz (89) [Avatar] Offline
#120
Re: Errors and Corrections
Listing 12.9, Numbering of "#A" is not provided on the line:

def n = System.lineSeparator() // #A (is supposed to follow the code)

Hoon
biospringxyz (89) [Avatar] Offline
#121
Re: Errors and Corrections
Last sentence before section 12.3.2, missing "of":

If you set out to deeply dive into the topic, get one (of) the excellent books on the topic.

Hoon
biospringxyz (89) [Avatar] Offline
#122
Re: Errors and Corrections
Missing "of" or "in" in the sentence:

"Basic relational database operations (of or in?) Groovy follows the design guideline that simple tasks should be easy and advanced tasks should be possible."

Hoon
paulk_asert (33) [Avatar] Offline
#123
Re: Errors and Corrections
> Listing 12.3 ... Should "Table" read "Listing"?

Corrected, thanks!
paulk_asert (33) [Avatar] Offline
#124
Re: Errors and Corrections
> Listing 12.6 ... No signature of method: java.io.BufferedInputStream.readLine() ...

That method was deprecated several years ago but the example wasn't updated. Thanks for spotting the problem.
paulk_asert (33) [Avatar] Offline
#125
Re: Errors and Corrections
> Last sentence before section 12.3.2, missing "of":

Fixed, thanks!
paulk_asert (33) [Avatar] Offline
#126
Re: Errors and Corrections
> Listing 12.8:
> 1. Timezone issue...

In the first edition we assumed the reader would change the script to their own timezone before running. I think your suggestion makes it nicer for readers. Fixed as per your suggestion.

> 2. map value ...

This is correct in old versions of Groovy but wrong now. Also fixed as per your suggestion.

Thanks!
paulk_asert (33) [Avatar] Offline
#127
Re: Errors and Corrections
> Listing 12.9, Numbering of "#A" is not provided...

Fixed. Thanks!
tomc (3) [Avatar] Offline
#128
Re: Errors and Corrections
Scripting the Web (page 11).

The web service used in the code sample no longer works:

http:://azarask.in/services/rhyme?q=movie
tomc (3) [Avatar] Offline
#129
Re: Errors and Corrections
Table 3.4 Method-based operators

Post decrement and pre decrement. The "--" doesn't appear.
tomc (3) [Avatar] Offline
#130
Re: Errors and Corrections
3.3.2 Overriden operators in action.

Reference to @Immutable annotation in 2.6, should be 2.3.4?
paulk_asert (33) [Avatar] Offline
#131
Re: Errors and Corrections
> assert plan.childNodes.length == 5
> why 5? it should be described

Explanation added.

> and small typo on page 356: ...

Someone seems to have already fixed that typo in the source files.

Thanks for your suggestions.
paulk_asert (33) [Avatar] Offline
#132
Re: Errors and Corrections
> The web service used [...] no longer works:

Already fixed, thanks,
paulk_asert (33) [Avatar] Offline
#133
Re: Errors and Corrections
> MEAP 1 page 356 ... page 360:

Yes, the hyperlinks got deleted somehow during the pdf publication. Should be fixed now, thanks.
biospringxyz (89) [Avatar] Offline
#134
Re: Errors and Corrections
Section 13.1.1, INSTALLING A DATABASE, 1st paragraph:

"Remember that you can drop a jar file into your <user.home>/.groovy/lib directory to have it on your class path whenever you start the groovy interpreter."

The directory hierarchy I could find in my Mac under "<user.home>/.groovy" leading to the file "h2-1.3.172.jar" is:

"<user.home>/.groovy/grapes/com.h2database/h2/jars/h2-1.3.172.jar"

Can this be related to "h2" and "JdbcDataSource" not being recognized in some Listings' DataSource-based database connections?

Hoon
paulk_asert (33) [Avatar] Offline
#135
Re: Errors and Corrections
> Table 3.4 [...] Post decrement and pre decrement. The "--" doesn't appear.

This was a pdf production glitch from a while back and should have already been fixed.
paulk_asert (33) [Avatar] Offline
#136
Re: Errors and Corrections
> "Basic relational database operations [in] Groovy ...

Fixed, thanks!
paulk_asert (33) [Avatar] Offline
#137
Re: Errors and Corrections
> 3.3.2 ... Reference to @Immutable annotation in 2.6, should be 2.3.4?

Yes, I think it originally said Listing 2.6 but it is now listing 2.5! In any case, I think it makes more sense to point to the section number 2.3.4 as you suggest. Thanks.
paulk_asert (33) [Avatar] Offline
#138
Re: Errors and Corrections
> Section 13.1.1, INSTALLING A DATABASE, 1st
> paragraph:
>
> "Remember that you can drop a jar file into your
> <user.home>/.groovy/lib directory to have it on your
> class path whenever you start the groovy
> interpreter."
>
> The directory hierarchy I could find in my Mac under
> "<user.home>/.groovy" leading to the file
> "h2-1.3.172.jar" is:
>
> <user.home>/.groovy/grapes/com.h2database/h2/jars/h2-1
> .3.172.jar"
>
> Can this be related to "h2" and "JdbcDataSource" not
> being recognized in some Listings' DataSource-based
> database connections?

No, you can either drop a copy of that jar into your .groovy/lib directory or you will need a @Grab('com.h2database:h2:1.3.172') and for some databases a @GrabConfig(systemClassLoader=true) at the top of your script.
biospringxyz (89) [Avatar] Offline
#139
Re: Errors and Corrections
Section 13.1.2, the last paragraph before the code on page 303:

"Your database vendor provides its own implementation of the javax.sql.DataSource interface. HSQLDB, for example, provides the class org.h2.jdbcx.JdbcDataSource for that purpose."

1) Should "HSQLDB" read "H2 database"?

2) The DriverManager-based listings work fine but the DataSource-based listings don't (in IntelliJ on Mac) because "JdbcDataSource" is not recognized even after putting "h2*.jar" in the "<user.home>/.groovy/lib" directory. Any clue as to why H2 database would work only partially?

Hoon

Hoon
paulk_asert (33) [Avatar] Offline
#140
Re: Errors and Corrections
> 1) Should "HSQLDB" read "H2 database"?

Yes, fixed. Thanks!

> 2) The DriverManager-based listings work fine but the
> DataSource-based listings don't (in IntelliJ on Mac)
> because "JdbcDataSource" is not recognized even after
> putting "h2*.jar" in the "<user.home>/.groovy/lib"
> directory. Any clue as to why H2 database would work
> only partially?

I have no problems running those examples. Some things you could try:
- check that the datasource class exists in your jar
- try running from the command-line instead of through IntelliJ (but I ran it fine using IntelliJ)
- does the hsqldb example later in the chapter work for you (there is also one using a datasource)?
biospringxyz (89) [Avatar] Offline
#141
Re: Errors and Corrections
1) Table 13.1: use of "HSQLDB" instead of "H2 database" in the title and the contents:

"Table 13.1 HSQLDB subprotocols"

"... Connects to a HSQLDB server..."

2) Listing 13.1, the parameter, "URL: 'jdbc:h2:mem:GIA;DB_CLOSE_DELAY=-1".
Should you stick with "GinA" instead of "GIA" for consistency's sake?

Hoon
dtonnofer (12) [Avatar] Offline
#142
Opening conneciton to the DB on page 307: Use named parameters, please!
Instead of

db = Sql.newInstance('jdbc:h2:mem:GinA','sa','','org.h2.Driver')

use

http://groovy.codehaus.org/api/groovy/sql/Sql.html#newInstance%28java.util.Map%29

db = Sql.newInstance([
url : 'jdbc:h2:mem:GinA',
user : 'sa',
password : '',
driverClassName : org.h2.Driver.class.name ])


Much clearer
paulk_asert (33) [Avatar] Offline
#143
Re: Opening conneciton to the DB on page 307: Use named parameters, please!
The sample code which comes with the book (but probably not available yet as part of MEAP) almost exclusively uses named parameters - though not as you have shown here but rather the datasource variant. We are currently working through the database chapter to make it clearer, so you might see some changes to make it closer to what you are after - though we probably do want to illustrate several options available to Groovy users of the Groovy SQL features.

Two advantages to the current approach:
* you will get IDE prompting/assistance to let you know the 4 String parameter versions but not for the map variant
* if you hard-code the driver (or the datasource class) into your script it will need to be available at compile and runtime to avoid class-loading errors to even load the script; whereas the String variant doesn't require the class at compile time - only runtime (and could be read for instance from a properties file) and the script itself will happily load at least even if the driver is not available at runtime and could potentially take appropriate action by catching the necessary exceptions.

Cheers, Paul.


> Instead of
>
> db =
> Sql.newInstance('jdbc:h2:mem:GinA','sa','','org.h2.Dri
> ver')
>
> use
>
> http://groovy.codehaus.org/api/groovy/sql/Sql.html#new
> Instance%28java.util.Map%29
>
> db = Sql.newInstance([
> url : 'jdbc:h2:mem:GinA',
> user : 'sa',
> password : '',
> driverClassName : org.h2.Driver.class.name ])
>
>
> Much clearer
pjwalsh (1) [Avatar] Offline
#144
Re: Errors and Corrections
in section 1.3.2 there is a screenshot of Groovy Object Browser (fig 1.6 in MEAP15). However, there is no reference to how to start the object browser, it just suddenly appears there. Would be nice to have this fixed for the final release
bodiam (27) [Avatar] Offline
#145
Re: Errors and Corrections
Hi Pjwalsh,

Good suggestion, I've added it.By now, you've probably found it, but you can access it by going to Script -> Inspect variables.

Thanks, Erik Pragt
biospringxyz (89) [Avatar] Offline
#146
Re: Errors and Corrections
Chapter 13, the code before "NOTE FOR ENTERPRISE DEVELOPERS":

source = new org.h2.jdbcx.JdbcDataSource()
source.database = 'jdbc:h2:mem:GinA'
source.user = 'sa'
source.password = ''
db = new groovy.sql.Sql(source)

I have two problems with this code:

1) the database property is not available under the "source" object (JdbcDataSource instance with latest H2 jar and IntelliJ). The only alternative I found to be palatable is the "setURL()" method as in:

source.setURL('jdbc:h2:mem:GinA')

2) Although the code with the "setURL()" method for creating a connection and the "db.execute()" method for creating the "ATHLETE" table executes without throwing an exception, insertion of athlete records fails as follows:

======== Test code ====================
source = new org.h2.jdbcx.JdbcDataSource()
//source.database = 'jdbc:h2:mem:GinA' // This line doesn't seem to work.
source.setURL('jdbc:h2:mem:GinA')
source.user = 'sa'
source.password = ''

db = new groovy.sql.Sql(source)

db.execute '''
DROP INDEX athleteIdx IF EXISTS;
DROP TABLE Athlete IF EXISTS;

CREATE TABLE Athlete (
athleteId INTEGER GENERATED BY DEFAULT AS IDENTITY,
firstname VARCHAR(64),
lastname VARCHAR(64),
dateofbirth DATE
);
'''

def athletes = [
[first: 'Paul', last: 'Tergat', dob: '1969-06-17'],
[first: 'Khalid', last: 'Khannouchi', dob: '1771-12-22'],
[first: 'Ronaldo', last: 'da Costa', dob: '1970-06-07']
]

athletes.each { athlete ->
db.execute """
INSERT INTO Athlete (firstname, lastname, dateofbirth)
VALUES (${athlete.first}, ${athlete.last}, ${athlete.dob})
"""
}

====== error message from IntelliJ when the above code is executed =========

Aug 30, 2013 2:56:28 PM groovy.sql.Sql execute
WARNING: Failed to execute:
INSERT INTO Athlete (firstname, lastname, dateofbirth)
VALUES (?, ?, ?)
because: Table "ATHLETE" not found; SQL statement:

INSERT INTO Athlete (firstname, lastname, dateofbirth)
VALUES (?, ?, ?)
[42102-173]
Caught: org.h2.jdbc.JdbcSQLException: Table "ATHLETE" not found; SQL statement:

INSERT INTO Athlete (firstname, lastname, dateofbirth)
VALUES (?, ?, ?)
[42102-173]
org.h2.jdbc.JdbcSQLException: Table "ATHLETE" not found; SQL statement:

INSERT INTO Athlete (firstname, lastname, dateofbirth)
VALUES (?, ?, ?)
[42102-173]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:331)
at org.h2.message.DbException.get(DbException.java:171)
at org.h2.message.DbException.get(DbException.java:14smilie
at org.h2.command.Parser.readTableOrView(Parser.java:4864)
at org.h2.command.Parser.readTableOrView(Parser.java:4842)
at org.h2.command.Parser.parseInsert(Parser.java:974)
at org.h2.command.Parser.parsePrepared(Parser.java:375)
at org.h2.command.Parser.parse(Parser.java:279)
at org.h2.command.Parser.parse(Parser.java:251)
at org.h2.command.Parser.prepareCommand(Parser.java:21smilie
at org.h2.engine.Session.prepareLocal(Session.java:42smilie
at org.h2.engine.Session.prepareCommand(Session.java:377)
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:113smilie
at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:70)
at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:644)
at com.demo.Listing_13_OpenH2DB$_run_closure1.doCall(Listing_13_OpenH2DB.groovy:81)
at com.demo.Listing_13_OpenH2DB.run(Listing_13_OpenH2DB.groovy:7smilie
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

Process finished with exit code 1
Eric Pierce (2) [Avatar] Offline
#147
Re: Errors and Corrections
Version 16
See 2.3.7 Lists Code example.

You have:
roman.size() == 9

I presume you want:
assert roman.size() == 9
biospringxyz (89) [Avatar] Offline
#148
Re: Errors and Corrections
MEAP, SE, V16, Section 1.5, 2nd paragraph, 2nd sentence, Typo:

"It must be, because in a dynamic language, new methods9 may become available at runtime that the compiler cannot foresee."

"methods9" should read "methods"?
Mittie (397) [Avatar] Offline
#149
Re: Errors and Corrections
yep, thanks for the finding!

cheers
Dierk
Eric Pierce (2) [Avatar] Offline
#150
Re: Errors and Corrections
In ver. 16 / 2013-08-27:

Under Listing 4.15 you have:
def addTo = []
myMap.collect(addTo) { entry -> entry.value *= 2 }
assert doubled instanceof List
assert addTo.every { item -> item % 2 == 0 }

I believe you meant:
def addTo = []
myMap.collect(addTo) { entry -> entry.value *= 2 }
assert addTo instanceof List
assert addTo.every { item -> item % 2 == 0 }
Mittie (397) [Avatar] Offline
#151
Re: Errors and Corrections
True! Very observant!
It's even an error in the first edition that nobody has reported before smilie
( since of course the code is correct but it did not assert what it should have )

Thanks a lot!
Dierk
biospringxyz (89) [Avatar] Offline
#152
Re: Errors and Corrections
Section 3.1.4, 1st paragraph:

"If in 1+1 both numbers are objects of type Integer, you may be wondering whether those Integers unboxed to execute the plus operation on primitive types."

Should it read:

"If in 1+1 both numbers are objects of type Integer, you may be wondering whether those Integers are unboxed to execute the plus operation on primitive types."

Hoon
biospringxyz (89) [Avatar] Offline
#153
Re: Errors and Corrections
Section 3.2.2, a code snippet:

"Integer myInt = returnsObject() println(++myInt)"

Should this be printed in two lines as in:

Integer myInt = returnsObject()
println(++myInt)

Hoon
biospringxyz (89) [Avatar] Offline
#154
Re: Errors and Corrections
Section 3.2.2, Last Paragraph: the use of expression: "XREF method_dispatch"

Is it supposed to refer to a separate (presumably later in the book) section with more explanation on the topic? If so, then I couldn't find it in any other part of the book.

Hoon
Mittie (397) [Avatar] Offline
#155
Re: Errors and Corrections
Hi Hoon,

thanks a lot for the corrections.
References are not yet all updated - this will be part of the final copy-editing.
Giving notice of missing newlines in code is important, though. It seems this has happened in the typesetting and is not in the original files. *sigh*

keep 'em coming! smilie
Dierk
biospringxyz (89) [Avatar] Offline
#156
Re: Errors and Corrections
Listing 3.7 Regular expressions, the first comment mixed with a line of code:

// twister must contain a substring of size 3
// that starts with s and ends with a assert twister =~ /s.a/ // #1 Regex
find operator as

Should it be cleaned up as:

// twister must contain a substring of size 3
// that starts with s and ends with a.
assert twister =~ /s.a/ // #1 Regex find operator

Hoon
biospringxyz (89) [Avatar] Offline
#157
Re: Errors and Corrections
First paragraph, p77:

"The interesting part comes with groupings in the match. If the pattern contains parentheses to define groups, then the result of asking for a particular match is an array of strings are than a single one"

Should it read:

"The interesting part comes with groupings in the match. If the pattern contains parentheses to define groups, then the result of asking for a particular match is an array of strings rather than a single one"
cranberry (1) [Avatar] Offline
#158
Re: Errors and Corrections
MEAP V16
Page 690
Listing 20.21

Not *completely* sure about this one, because I'm still learning Griffon...

"
def action = {
sendMail(transport: 'smtps', auth: true,

"
The documentation for the mail plugin Ver 1.1.1 states that the method is "withMail" rather than "sendMail"

"
Sending an email via Google's SMTP server:

withMail(transport: 'smtps',
auth: true,
"
HamletDRC (6) [Avatar] Offline
#159
Re: Errors and Corrections
You are right. "sendMail" has been changed to "withMail" since the chapter was written.

Thanks!
biospringxyz (89) [Avatar] Offline
#160
Re: Errors and Corrections
MEAP, v17, Listing 4.9, the last comment in the code and the beginning sentence of the section that follows the code:

"//#C AccumulationUnderstanding and using the inject method can be a bit challenging if you’re new to the concept."

This should be separated:

"//#C Accumulation

Understanding and using the inject method can be a bit challenging if you’re new to the concept."

Hoon
joergst (1) [Avatar] Offline
#161
Re: Errors and Corrections
MEAP 17 PDF, p. 138. The link to the article by Andrew Glover is not correct. It should read http://www.ibm.com/developerworks/library/j-pg08235/. BTW it lists 4 authors, not only one.
Meanwhile three additional articles about functional programming with Groovy were published on IBM Developer Works in 2011/12, all written by Neal Ford, very interesting to read and quite up-to-date.
Mittie (397) [Avatar] Offline
#162
Re: Errors and Corrections
well spotted, thanks!

The whole topic of functional programming with Groovy has grown meanwhile and we will have to rethink the reference - probably pointing to some of Paul's talks on the topic.

cheers and thanks
Dierk
paulk_asert (33) [Avatar] Offline
#163
Re: Errors and Corrections
> Listing 3.7 Regular expressions, the first comment
> mixed with a line of code:

Thanks Hoon, this should already be fixed in MEAP v17. Thanks for the feedback.
paulk_asert (33) [Avatar] Offline
#164
Re: Errors and Corrections
> Section 3.2.2 [... formatting issues ...]

The two errors you spotted should already be fixed in MEAP v17. Thanks!
paulk_asert (33) [Avatar] Offline
#165
Re: Errors and Corrections
> First paragraph, p77 ...

Should be fixed in MEAP v17. Thanks!
paulk_asert (33) [Avatar] Offline
#166
Re: Errors and Corrections
> "methods9" should read "methods"?

The "9" is a footnote, hopefully the formatting is correct in MEAP v17. Thanks!
paulk_asert (33) [Avatar] Offline
#167
Re: Errors and Corrections
> roman.size() == 9

Should be fixed in MEAP v17. Thanks!
Ed Clark (1) [Avatar] Offline
#168
Re: Errors and Corrections
There seem to be a few section pointer issues since the builder info moved from being in Chapter 8 to being in Chapter 11. You'd probably catch them at some point, but if I can save you a couple of minutes....

This is for v17 of the MEAP.

Last sentence in Section 5.7.2 - page numbered 144 (PDF page 14smilie
'chapter 8' -> 'chapter 11' and 'section 8.6' -> 'section 11.7'

Second to last paragraph in Section 7.1.4 - page 177 (PDF page 181)
'section 8.5.7' -> 'section 11.5.2'? or 'section 11.5.7'?

Page 206 (210 in the PDF), second 'BY THE WAY' paragraph, last line.
'chapter 8' -> 'chapter 11'

Second bullet item in the introduction of Chapter 8 - page 212 (PDF 216)
'chapter 10' -> 'chapter 11'

Last sentence of 10.1.4 - page 298 (PDF 302)
'section 10.5' -> 'section 10.4.1'

Footnote 118 on page 328 (PDF 332) needs updating.
'chapter 12' -> 'chapter 14'
biospringxyz (89) [Avatar] Offline
#169
Re: Errors and Corrections
v17, section 5.7.2, 1st paragraph:

"The bBuilder pattern serves to encapsulate the logic associated with constructing a product from its constituent parts."

Should "bBuilder" read "Builder"?

Hoon
biospringxyz (89) [Avatar] Offline
#170
Re: Errors and Corrections
Listing 6.9, the last comment of the listing and the first sentence of the paragraph that follows are mixed up as one:

"//#7 Implicit typing, over string as collection, bracesThe example (#1) uses explicit typing for s and no braces for a loop body of a single statement."

Hoon
oleg.estekhin (1) [Avatar] Offline
#171
Re: Errors and Corrections
Hi

I am reading the book in different formats on different devices and would like to point to some technical problems:

So far the pdf is most consistent.

Kindle has problems with some tables - no matter how small the font some tables do not fit the screen, that is I can't see some text at the end of right-most column.

epub variant is most inconsistent. I tried a lot of different readers and they all have some problems. As far as I can tell, half of these problems are from the reader application side, but other half is from the contents of the epub variant.

Consider the very first code example. The relevant html code inside epub is:

 

<code class="Code"><span><code class=""CodeChar"">new</code></span> <span><code class=""CodeChar"">MyGroovyClass();</code></span> <span><code class=""CodeChar"">//</code></span> <span><code class=""CodeChar"">create</code></span> <span><code class=""CodeChar"">from</code></span> <span><code class=""CodeChar"">Java</code></span></code> <code class="Code"><span class="sgc24"> </span></code>

I am not sure that "CodeChar" is a good class name for html, and I am not sure that a lot of extra spans help too.

Some paragraphs inside epub/html use just a simple

tag, but some look like this:
< p class="Body8">< span class="sgc19">Let’</span>s < span class="sgc19">tak</span>e a < span class="sgc19">close</span>r < span class="sgc19">loo</span>k < span class="sgc19">a</span>t < span class="sgc19">wha</span>t <span class="sgc19">make</span>s <span class="sgc19">Groov</span>y <span class="sgc19">s</span>o <span class="sgc19">appealing</span>, <span class="sgc19">startin</span>g <span class="sgc19">wit</span>h <span class="sgc19">ho</span>w Groovy <span class="BodyChar">and</span> <span class="BodyChar">Java</span> <span class="BodyChar">work</span> <span class="BodyChar">hand-in-hand.</span>



This is surely a lot of unneeded spans. It is valid html code, but it is just too much for some (most?) epub readers.


Please, review the process by which you produce the epub code and, if, possible modify it so that it generates a cleaner epub/html.

edited the html cope-paste so that markup is visible
biospringxyz (89) [Avatar] Offline
#172
Re: Errors and Corrections
Listing 7.5, method "void publicVoidMethod()" has indentation not aligned with other methods:

void publicVoidMethod() {
____}
____def publicUntypedMethod(){
_______return 'hi'
____}


Hoon
biospringxyz (89) [Avatar] Offline
#173
Re: Errors and Corrections
Listing 7.21, the assert statement for "metaClass" fails:
===========================================
assert store.contains('metaClass')
_______|___|
_______|___false
_______[class, class com.manning.groovyinaction.SomeClass, someProperty, null]
===========================================

The "metaClass" property doesn't seem to be returned in "obj.properties".

Hoon
biospringxyz (89) [Avatar] Offline
#174
Re: Errors and Corrections
Section 7.4.4., 1st paragraph after the bullet list, 2nd sentence:

"You can also use a GString: def name = 'my-name'; object. "$name"."

The space between "object." and "$name" is confusing. The text auto formatter seems to be treating the dot notation (".") as a period.

Hoon
biospringxyz (89) [Avatar] Offline
#175
Re: Errors and Corrections
Figure descriptions, 7.1 and 7.3:

"Figure 7.1 depicts the corresponding software model in a UML class diagram. The Invoice class aggregates multiple LineItems that in turn refer to a Product."

"Figure 7.3 UML class diagram of an Invoice class that aggregates multiple instances of a LineItem class, which in turn aggregates exactly one instance of a Product class."

Both seem to refer to the same diagram which is Figure 7.3 and there is no figure corresponding to the Figure 7.1 description.

Hoon
biospringxyz (89) [Avatar] Offline
#176
Re: Errors and Corrections
The paragraph after the 4 methods of GroovyObject refers to "GroovyObject.invokeMethod"

but the "GroovyObject." is separated from "invokeMethod" due to the auto-formatting so it looks:

"GroovyObject.____invokeMethod"

(Underline for space) which is confusing.

Hoon
biospringxyz (89) [Avatar] Offline
#177
Re: Errors and Corrections
My previous posting was regarding section 7.6.1. Sorry about that.

Hoon
biospringxyz (89) [Avatar] Offline
#178
Re: Errors and Corrections
Section 8.3.1, 1st sentence:

"Whenever a method cannot be found in the target object, the MOP tries looks for the hook method"

"tries looks for" should read "tries to look for"

Hoon
biospringxyz (89) [Avatar] Offline
#179
Re: Errors and Corrections
Listing 8.18, 2nd assert statement:

"assert xMas.date == 24"

This assert fails unless the timezone is set to GMT.
biospringxyz (89) [Avatar] Offline
#180
Re: Errors and Corrections
Section 8.4.6, the small note block between the 2nd and the 3rd paragraphs, headed by, "REUSE BY...":

"REUSE BY INHERITANCE IN QUESTIONABLE"

Is it meant to say, "REUSE BY INHERITANCE IS QUESTIONABLE"?

Hoon
biospringxyz (89) [Avatar] Offline
#181
Re: Errors and Corrections
Section 8.4.6, the 1st sentence of the 4th paragraph:

"If you have a superclass A with a subclass B than any object of class B is not only a B, it also is an A!"

Should it read,

"If you have a superclass A with a subclass B then any object of class B is not only a B, it also is an A!"?

Hoon
biospringxyz (89) [Avatar] Offline
#182
Re: Errors and Corrections
Listing 8.20, the @Mixin statement:

@Mixin(MessageFeature)

is flagged (by IntelliJ) as having the problem:

"Expected 'MessageFeature' to be an inline statement"
biospringxyz (89) [Avatar] Offline
#183
Re: Errors and Corrections
Oops, I just realized that I had not typed the Listing 8.20 code properly into IntelliJ. Please ignore the issue:

Listing 8.20, the @Mixin statement:

@Mixin(MessageFeature)

is flagged (by IntelliJ) as having the problem:

"Expected 'MessageFeature' to be an inline statement"
biospringxyz (89) [Avatar] Offline
#184
Re: Errors and Corrections
Towards the end of section 8.4, one of the bullet items summarizing Mixin:

"There are no restrictions what methods to mix in."

Should it read:

"There are no restrictions on what methods to mix in"
biospringxyz (89) [Avatar] Offline
#185
Re: Errors and Corrections
Listing 9.8 is missing. Listing number jumps from 9.7 to 9.9.
biospringxyz (89) [Avatar] Offline
#186
Re: Errors and Corrections
A typo in the 2nd sentence in the 2nd paragraph after Listing 9.11:

"The @Immutable annotation is very intelligent about which fields to handle. All fields in an @Immutable class must also be marked Immutable, or be of a know immutable type such as a primitive type, String, Color, or URI"
biospringxyz (89) [Avatar] Offline
#187
Re: Errors and Corrections
In section 9.2.3, use of @Log annotations is explained. However, the mechanisms to see the contents of the log are not shown.
Mittie (397) [Avatar] Offline
#188
Re: Errors and Corrections
chapter 7/8 in general:

Thank you all for your mindful comments! They are very much appreciated. I just wanted to mention that I have chapters 7 and to a lesser extend also 8 in work and the text will anyway change quite a bit.

cheers
Dierk
jamgard (9) [Avatar] Offline
#189
Re: Errors and Corrections
Section 4.2.3
PDF page 109-110

text on p.109 says that eachReverse is a method of lists

code on p.110 references reverseEach

reverseEach is the correct one.

This is a holdover error from the 1st edition.
Mittie (397) [Avatar] Offline
#190
Re: Errors and Corrections
excellent observation!

thank a lot
Dierk
jamgard (9) [Avatar] Offline
#191
Re: Errors and Corrections
Page 131 of MEAP (pdf)

You refer to:
first.&validate and second.&validate in text for Listing 5.2, but probably should be filter6.&sizeUpTo and filter5.&sizeUpTo

The first edition does, however, have the references for first.&validate and second.&validate in the corresponding listing
jamgard (9) [Avatar] Offline
#192
Re: Errors and Corrections
p. 137 first paragraph
Formatting for "reference" in "this.reference" and "plain reference" were originally italicized in first edition.
Losing this makes the passages more confusing.

Also, the footnote has not been resolved from the first edition. It refers to missing information at the time of the first edition. Has the info not been found out yet?
jamgard (9) [Avatar] Offline
#193
Re: Errors and Corrections
p. 138
Old references to code in first edition:
field should be prop
foo() should be method()

and on p.139
The image has the same referring problem as the previous page
Mittie (397) [Avatar] Offline
#194
Re: Errors and Corrections
thanks, James!
biospringxyz (89) [Avatar] Offline
#195
Re: Errors and Corrections
Example 10.25: code is missing
jamgard (9) [Avatar] Offline
#196
Re: Errors and Corrections
p.157-158

I've tested the code in listing 6.7 with both groovy 2.2.1 and 1.8.9.
assertHost does not fail with the last two examples but is not being matched by the regex. To check just add "println 'foo';" to the closure (or is it a code block? Still learning Groovy.) just before the "assert it[1]==expected".

It will print three foo's and then stop, but not fail via assertion. I don't know if the "host" regex is to blame. It matches the first three examples. eachMatch isn't matching the candidate (and I ain't a regex master)

This was also in the first edition.
jamgard (9) [Avatar] Offline
#197
Re: Errors and Corrections
p. 169 Listing 7.2

The variable (constant) PI can't be static here - it fails on groovy 1.8.9 and 2.2.1.
Removing the static works though.
Leftover from first edition.
biospringxyz (89) [Avatar] Offline
#198
Re: Errors and Corrections
Listing 11.14 (Example of a table backed by table Model...) is the same code used in Listing 11.4 (Invoice with NodeBuilder).
biospringxyz (89) [Avatar] Offline
#199
Re: Errors and Corrections
Section 11.6, 1st paragraph, 2nd sentence, a typo:

"JavaFX 2 is included in all Java 7 distributions since update 10 and JavaFX 8 comes bundeled with Java 8."

It should read, "bundled".
jamgard (9) [Avatar] Offline
#200
Re: Errors and Corrections
pp. 192-193

Listing 7.21

metaClass is *not* working with Groovy 2.2.1.

This listing *does* work with 1.8.9.