I
I
Ivan Velichko2012-07-18 10:52:02
infographics
Ivan Velichko, 2012-07-18 10:52:02

What is the difference between "Generalization", "Implementation" relationships and "Implementation" on a UML class diagram?

I can't figure out how (and if there is) a fine line between the following types of relationships in a UML class diagram:

  • generaliztion (generalization)
  • realization (implementation)
  • implementation (implementation)

I understand the UML specification regarding this issue as follows:
- the generalization relationship occurs between classes when one class (heir) is based on another class (parent). Apparently, here the parent class must be a concrete class (that is, you can create instances of it).
A realization relationship occurs between elements of a class diagram when one class implements a behavior defined by another class. Most likely, here we are talking about the implementation of behavior defined by an interface or an abstract class.
— the implementation link is a subtype of the realization link. Apparently, at one end of the connection is a concrete class, and at the other end is an interface (interface in Java, pure virtual class in C ++).
Question one:how accurate is my interpretation of the specification?
Question two: can realization be considered a subtype of the generalization relationship?
Question three: if the language supports multiple inheritance (C ++ for example) and the class is inherited from two specific classes - what is the relationship between the heir and superclasses in this case?
I understand the semantic difference between an interface and an abstract class. The parent abstract class defines the essence of an object, and a class's implementation of some interface is just one aspect of the class's behavior (or actions that can be performed on that class).
Question four: can it be that in one case, inheritance from an abstract class generates a generalization relationship, and in another case, realization.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Anton Bukov, 2012-07-18
@k06a

The interpretation is not entirely correct, I will now state my opinion, and comparing our views is not an easy task)) The main problem is the difference between concepts in UML and OOP.
In general, by definition : On the client side, each specific class has: an interface (which consists of methods, properties and other language pieces) and an abstraction (this is some kind of behavior that is implied when interacting with its interface).
generalization. When classes have the same behavior, it turns out that their interfaces can be reduced to a single one - to generalize. A generalization diagram shows the similarity of some aspect of the behavior and the absolute similarity of the interface.
Realization.When part of the behavior of an object is taken out in a separate class, this is called an implementation. In programming, this technique is usually called delegation, but the UML seems to think otherwise.
implementation. In UML terminology, this just means the decomposition of an object into its component parts. In programming, this term means something completely different…

E
eaa, 2012-07-18
@eaa

This is very entertaining ... I have never dug so deeply, and now ...
Even in Russian, “realization” and “implementation” are translated as implementation - I kind of knew this, but I have not seen such a division anywhere in the literature. Searching for "realization" on the wiki also did nothing, which is already alarming. But about implementation it is written that this is realization :)
“Implementation is the realization of an application, or execution of a plan, idea, model, design, specification, standard, algorithm, or policy.”
Okay, I think it's the same thing.
Then we have that generalization is just inheritance, it does not matter whether it is from an abstract class or not.
Implementation is an implementation of an interface (or a purely abstract class).
So, I don't know what to say about the first question, but I expressed my opinion.
On the second, it is possible, with some clarification, that this will be implemented (realized, implemnted) already by a real method, which simply could not be implemented in the interface simply because it is an interface.
According to the third, there will be just a few connections, depending on the type - for example, if several interfaces are implemented, then there will be several “implementation” connections, the same applies to generalization.
According to the fourth, if a vlass extends the abstract and does not implement anything itself (i.e., it is also abstract), then there simply cannot be an implementation (implementation, realization) - i.e. here is purely generalization. And if something is actually implemented, then we can talk about implementation (realization).

J
jorikburlakov, 2012-07-18
@jorikburlakov

1) Like implementation, this is the implementation. The concept of inheritance and implementation seems to be correct.
2) Well, both of these relationships are relationships at the object level, but whether realization can be considered a subtype of the generalization relationship, I will not answer you.
3) I think generalization.
4) It seems to me not, since generalization is used, the state is inherited too.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question