OOPortal OOPortal

Logical View  «Prev 

Different Views of a Class and Class Compartments

Additional class views

Many tools also support different views of the operations, for example, name, argument data types, and return data type only, or with fully expanded arguments.

Serial Version Ids

When you receive an Eclipse warning saying that the class does not contain a serial version identifier.
Eclipse will offer to generate a random one for you, which boils down to a line of code similar to this one being added to your class:
private static final long serialVersionUID = -8952857142790654268L;

Now what is this identifier and why is it useful? The reason behind this has to do with serialization (storing objects in a format that allows you to read them back out and initialize them as class instances again later). To make sure that the data of a stored object still matches a class definition (as this might have changed over time), Java also stores a special identifier that verifies that the object to be loaded back in still matches the identifier of the class. As such, as the name suggests, the serialVersionUID is mainly helpful for versioning reasons (an object with UID 100 will not be able to get instantiated to its class when the class definition is on version 101).
In most cases, Java can generate a serialVersionUID based on various aspects of the class at hand. However, it is recommended that all serializable classes explicitly declare serialVersionUID values, since the default serialVersionUID computation is sensitive to class details that may vary depending on compiler implementations. Since Swing components implement Serializable and because Eclipse cares about best practices, it asks you to specify a serialVersionUID.
The best thing to do if you want to avoid these warnings is to use the default UID everywhere:
private static final long serialVersionUID = 1L;

Class without full signature

Suppressed or hidden class details

The UML supports user-defined compartments as well. You can define virtually any type of information to append to a class by creating additional compartments. At this time, I am unaware of any tools that allow you to take advantage of this feature.