Could you clarify a bit the reason(if there is) why you didn't try to cover all static data, static methods, static blocks and static classes into chapter-6, which is titiled as Static, Final and Enumeration Types?
Hi Ko Ko,
You raise a good point here, which is "how does a writer decide what to cover in a chapter"?
The answer is that it is a tradeoff with many competing elements. The two starting points
are that you know there is some amount of material relating to topic A that you want to cover.
And you know that readers cannot tolerate a chapter longer than a certain length, no matter
how interesting you try to make it.
So those represent the boundaries for the material - one pushing to get more in, and the
other pushing to keep it smaller and more manageable.
The chapters before this one cover most of the other elements in the
Java type system, so I
knew that it was time to introduce enums. However, I had not covered static or final yet.
And since enums are final static objects, that was absolutely necessary groundwork, and in fact
a logical place to put them.
However, I certainly didn't want to bring in all the other uses of static too, like static imports,
static blocks, and static classes. They are not necessary to understand enums, and they
would balloon the chapter up in size. So you make a deliberate decision to postpone that
part of static, and just deal with the things people need to understand enums.
Every writer makes this kind of tradeoff (though they all make different decisions about
what to split off and to where). One of the ways to judge a book is to look not only at
what it covers, but also at how consistently it covers it, and in what order. Whenever I look
at a new programming language book, one of the first things I look for is an explanation of
associativity (assuming the language uses associativity to parse its expressions). This is a
topic that is often poorly understood and poorly explained. But it is *essential* for a proper
understanding of how expressions are evaluated. Try it! Pick up your favorite programming
book (not just Jave book) and look for the description of associativity!
Cheers,
Peter