Friday, September 23, 2011

Realization in UML


In this article we will learn how to implement Realization in UML. Realization shows the relationship between an Interface an the class that provides the implementation for the interface.
We can implement this in UML using a closed, hollow arrowhead pointing from the implementation class to the interface with a dashed line.
Interface In UML:
Similar to Class Diagram Structure in UML, we can show Interface Class in UML.
Interface in UML
Interface in UML
Realization Example:
Interface Code:
public interface Mammals {
    public String walk();
}


Interface Implementation Class:
public class Cats implements Mammals {
    public String walk() {
        return "Have Instructed Cats to Perform Walk Operation";
    }
}
 
public class Dogs implements Mammals {
    public String walk() {
        return "Have Instructed Dogs to Perform Walk Operation";
    }
}
Realization UML Diagram:
Implementing Realization in UML
Implementing Realization in UML


Realization relationships

In UML modeling, a realization relationship is a relationship between two model elements, in which one model element (the client) realizes the behavior that the other model element (the supplier) specifies. Several clients can realize the behavior of a single supplier. You can use realization relationships in class diagrams and component diagrams.
Typically, realization relationships do not have names. If you name a realization, the name is displayed beside to the realization connector in the diagram.
As the following figure illustrates, a realization is displayed in the diagram editor as a dashed line with an unfilled arrowhead that points from the client (realizes the behavior) to the supplier (specifies the behavior).
A component shape, called Component2, connected to a class, called Class3, by a dashed line. A hollow arrowhead  points from the component to the class.
You can model the following situations using realization relationships:
  • A component is realized by a set of classifiers that provide its implementation.
  • A collaboration instance contains the objects and messages that are needed to implement the behaviors that a use case specifies.
Feedback
(C) Copyright IBM Corporation 2004, 2005. All Rights Reserved. 

No comments:

Post a Comment