Zookeeper
Organizing attributes and operations
Organization attributes and operations
When drawing a class, you don't have to show every attribute and every operation at once. in fact, in most cases, you can't (there are too records of them to put in one figure) and you probably shocould not (only a subset of these attributes and operations are likely to be relevant to a specific view ). for these reasons, you can Elide a class, meaning that you can choose to show only some or none of a class's attributes and operations. you can indicate that there are more attributes or properties than shown by ending each list with an ellipsis ("... "). you can also suppress the compartment entirely, in which case you can't tell if there are any attributes or operations or how many there are.
When you draw a class, you do not need to display each attribute and each operation at the same time. in fact, in most cases, you cannot (there are too many to put them in a single region) or do not want to (only some attributes and operations seem to be related to the specified view. for this reason, you can omit a class, which means you can choose not to display or only display some attributes or operations of the class. you can use a ellipsis to indicate more attributes or operations at the end of the list. if you cannot tell whether there are attributes or operations or how many of them are there. you can also limit the separation bar.
To better organize long lists of attributes and operations, you can also prefix each group with a descriptive category by using stereotypes, as shown in Figure 4-7.
A better way than organizing a long string of attributes and operation lists is to add a prefix to each descriptive category group by using the pattern, as shown in 4-7.
Responsibilities
Responsibilities
Aresponsibilityis a contract or an obligation of a class. when you create a class, you are making a statement that all objects of that class have the same kind of state and the same kind of behavior. at a more abstract level, these corresponding attributes and operations are just the features by which the class's responsibilities are carried out. A wall class is responsible for knowing about height, width, and thickness; A fraudagentclass, as you might find in a credit card application, is responsible for processing orders and determining if they are legitimate, suspect, or fraudulent; A temperaturesensor class is responsible for measuring temperature and raising an alarm if the temperature reaches a certain point.
The responsibility is a type of contract or obligation. when you create a class, you are declaring the state and action of all objects in the class. at a more abstract level, the features displayed after the class's responsibilities are the corresponding attributes and operations. the purpose of a wall class is to understand the height, width, and thickness of the wall. For a fraud agent class, you can find it when applying for a credit card, this category is responsible for processing orders and determining whether these applications are authentic, suspicious, or fraudulent; a temperature sensor category is responsible for measuring the temperature and issuing an alert when the temperature reaches the defined value.
When you model classes, a good starting point is to specify the responsibilities of the things in your vocabulary. techniques like CRC cards and Use Case-based analysis are especially helpful here. A class may have any number of responsibilities, although, in practice, every well-structured class has at least one responsibility and at most just a handful. as you refine your models, you will translate these responsibilities into a set of attributes and operations that best fulfill the class's responsibilities.
When you build a class model, a good starting point is to describe the responsibilities of all things in the vocabulary. such as CRC card and basic case analysis technology are particularly helpful here. A class can have any number of responsibilities, although in fact, each class with a good structure has at least one responsibility and most of the time there are not many responsibilities. as a model you define, you will convert these responsibilities into a set of attributes and operations to best implement class responsibilities.
Graphically, responsibilities can be drawn in a separate compartment at the bottom of the class icon, as shown in Figure 4-8.
In graphical representation, duties are drawn in the separation bar at the lowest part of the class chart, which is displayed 4-8.
Note: responsibilities are just free-form text. In practice, a single responsibility is written as a phrase, a sentence, or (at most) a short paragraph.
Note: The responsibility is a free text. In practice, a single responsibility is expressed by a phrase, sentence, or (in most cases.
Other characteristics
Other features
Attributes, operations, and responsibilities are the most common features you'll need when you create your actions. in fact, for most models you build, the basic form of these three features will be all you need to convey the most important semantics of your classes. sometimes, however, you'll need to visualize or specify other characteristics, such as the visibility of individual attributes and operations; language-specific features of an operation, such as whether it is polymorphic or constant; or even the exceptions that objects of the class might produce or handle. these and incluother features can be expressed in the UML, but they are treated as advanced concepts.
When you create abstract things, attributes, operations, and responsibilities are the most common features. in fact, the basic form of these three features will convey the most important semantics of the class for most models you build. however, sometimes you need to visualize or describe other features, such as the uniqueness of an individual attribute or operation; the language characteristics of an operation, such as whether it has polymorphism, or is it a constant, or even an exception that a class object may generate or handle. these or more other features can be expressed in UML, but they are considered a deeper concept.
When you build models, you will soon discover that almost every action you create is some kind of class. sometimes you will want to separate the implementation of a class from its specification, and this can be expressed in the UML by using interfaces.
When you build a model, you will soon find that almost every abstraction you create is of a certain type. sometimes you want to separate the implementation of a class from its description, which is expressed as an interface in UML.
When you start designing the implementation of a class, you need to model its internal structure as a set of connected parts. you can expand a top-level class through several layers of internal structure to get the eventual design.
When you design the implementation of a class, you need to build its internal structure as a set of connections. You can expand the top-level class and obtain the final design through the multi-layer connection of the internal structure.
When you start building more complex models, you will also find yourself encountering the same kinds of entities over and over again, such as classes that represent concurrent processes and threads, or classifiers that represent physical things, such as Applets, Java Beans, files, web pages, and hardware. because these kinds of entities are so common and because they represent important extends tural activities actions, the UML provides active classes (representing processes and threads) and threads, such as extract (represententphysical software components) and nodes (representing hardware devices ).
When you start to build a more complex model, you will also find that you constantly encounter the same entity, such as classes representing concurrent processes and threads, or classifier that expresses physical things, such as small applications, Java components, files, webpages, and hardware. because such entities are too common, and because they express important system architecture abstraction, UML provides activity classes (reflecting processes and threads) and classifiers, for example, artifacts and (physical software components) nodes (hardware devices)
Finally, classes rarely stand alone. rather, when you build models, you will typically focus on groups of classes that interact with one another. in the UML these societies of classes form collaborations and are usually visualized in class diagrams.
Finally, classes rarely exist independently. on the contrary, when you construct a model, you usually concentrate on a group of interacting classes. in UML, these groups form interactions, which are usually displayed in class diagrams.