Wednesday, February 22, 2012

Objects, classes, and UML

Classes in UML

A class is represented in UML by a rectangle with three compartments. These are
  • Class
  • attributes
  • operations()
The first compartment in the UML diagram contains the class name, which UML recommends is centered and in bold. It also contains general properties like package owner or stereotype.
The second compartment contains the class's attributes. Attributes are features within a classifier that describe a range of values that instances of the classifier may hold.
The third compartment contains the class's operations. Operations are services that can be requested from an object that affect its behavior.
UML recommends that the names of both attributes and operations are left-justified and in plain type.
When representing a class, you can choose to show
  • attributes but not operations
  • operations but not attributes
  • attributes and operations
Or if you don't want to show any of a class's attributes or operations, you can simply represent it with a plain rectangle.
The names you choose for classes should come directly from the vocabulary of the problem domain. This helps you to understand what each class should do, and how it should relate to other classes.

If you have difficulty in naming a class, this can mean that it is poorly defined, or serves no useful purpose and should be discarded.
The following is a standard UML convention for naming classes.
Class names should
  • be singular nouns
  • start with an uppercase letter
Although not a UML recommendation, if you need to give a class a name that uses more than one word, you should
  • push the words together
  • capitalize the initial letter of each word
There are no strict UML conventions for naming attributes and operations. But it is common practice to push together words in any attribute or operation names that use more than one word.

The initial letter of the first word in such names is not usually capitalized, but the initial letter of each word after the first is.

Objects in UML
The UML notation for objects is very similar to the notation used for classes. Just like a class, an object is represented with a rectangle – with or without compartments.
But in contrast to a class name, an object name is always
  • underlined
  • in plain type
An object name can include the name of the class to which it belongs. In this case the class name follows the object name, and the two are separated by a colon.

For example, suppose the object BankTeller belongs to the Employee class. So its object name is bankTeller:Employee.
You can represent an object whose name or particular identity is irrelevant or not specified.
You do this by
  • underlining the class name
  • putting a colon before it
In a payroll system for a bank, it wouldn't be necessary to specify whether objects involved with the system were tellers or managers.

Such objects could be represented anonymously, with just their class name. So you would name each of them :Employee.

Class and object diagrams
Class diagrams are one of the most important types of diagram in UML.

This is because they provide a clear view of the relationship between a proposed system and its problem domain. Also, they can be used in conjunction with many development tools to generate skeleton code (the definition of the classes).
Class diagrams show only the static structure of systems.
They can be used to show
  • single classes
  • large groups of classes
  • relationships between classes
But they do not show the dynamic behavior of classes or the sequence of steps needed for a class to complete a use case.
Class diagrams can depict various levels of abstraction in a system.

They can give a high-level view by showing packages, which are groups of related classes handling specific parts of system functionality.
Or they can focus on the precise details of a single class's attributes and operations.
Class diagrams show a general overview of a system.
Object diagrams are very similar to class diagrams – but they provide a view of what a system looks like at a particular point in time, when classes are instantiated. They are useful for showing concrete examples of how a system functions.


Objects and classes are both represented in UML by a rectangle. A class has three compartments in the rectangle to show its name, attributes, and operations. An object has two compartments: one for the name and one for the attributes and their values.

Class diagrams show the static structure of classes, while object diagrams depict how classes look when instances are created. Class diagrams can show single classes, relationships between classes, and packages.

In UML, it is recommended, but not mandatory, that class names should be in bold, be without spaces, and have the initial letters of each word capitalized. Object names should be underlined and in plain type.


much informative and got more information for your blogs. keep sharing more information for us. thanks.
Best CAT Coaching in Chennai

great technology found via your article and it's more interest to do first sight visitors also. keep do more interested thing via design article
Seo Company in India

Finding the time and actual effort to create a superb article like this is great thing. I’ll learn many new stuff right here! Good luck for the next post buddy..
Fresher Jobs
Fresher Opening

Thank you for taking the time to provide us with your valuable information. We strive to provide our candidates with excellent care and we take your comments to heart.As always, we appreciate your confidence and trust in us
Digital Marketing Company in India

Post a Comment