By Bloch J.

Show description

Read or Download Effective Java Programming Language Guide PDF

Similar object-oriented software design books

Java & XML: Solutions to Real-World Problems

With the XML ''buzz'' nonetheless dominating speak between net builders, there is a genuine have to how one can lower during the hype and placed XML to paintings. Java & XML indicates how you can use the APIs, instruments, and methods of XML to construct real-world purposes. the result's code and knowledge which are transportable. This moment version provides chapters on complicated SAX and complicated DOM, new chapters on cleaning soap and knowledge binding, and new examples all through.

Data Structures for Computational Statistics

Because the starting of the seventies desktop is on the market to take advantage of programmable pcs for numerous projects. through the nineties the has constructed from the massive major frames to private workstations. these days it's not merely the that's even more robust, yet workstations can do even more paintings than a primary body, in comparison to the seventies.

Object-Oriented Analysis, Design and Implementation: An Integrated Approach

The second one variation of this textbook comprises revisions in accordance with the suggestions at the first version. In a brand new bankruptcy the authors offer a concise creation to the rest of UML diagrams, adopting an identical holistic technique because the first variation. utilizing a case-study-based process for supplying a finished advent to the foundations of object-oriented layout, it includes:A sound footing on object-oriented innovations resembling periods, gadgets, interfaces, inheritance, polymorphism, dynamic linking, and so on.

Extra resources for Effective Java Programming Language Guide

Example text

To make this concrete, let's suppose we have a program that uses a HashSet. To tune the performance of our program, we need to query the HashSet as to how many elements have been added since it was created (not to be confused with its current size, which goes down when an element is removed). To provide this functionality, we write a HashSet variant that keeps count of the number of attempted element insertions and exports an accessor for this count. The HashSet class contains two methods capable of adding elements, add and addAll, so we override both of these methods: // Broken - Inappropriate use of inheritance!

This is not a purely theoretical problem. Several security holes of this nature had to be fixed when Hashtable and Vector were retrofitted to participate in the Collections Framework. Both of the above problems stem from overriding methods. You might think that it is safe to extend a class if you merely add new methods and refrain from overriding existing methods. While this sort of extension is much safer, it is not without risk. 3]. If you've given the subclass a method with exactly the same signature as the new superclass method, then you're now overriding it, so you're subject to the two 49 50 problems described above.

If the argument is null, the compareTo method should throw a NullPointerException. This is precisely the behavior that you get if you just cast the argument to the correct type and then attempt to access its members. The field comparisons themselves are order comparisons rather than equality comparisons. Compare object reference fields by invoking the compareTo method recursively. If a field does not implement Comparable or you need to use a nonstandard ordering, you can use an explicit Comparator instead.

Download PDF sample

Rated 4.74 of 5 – based on 48 votes