Uncategories Tutorial :How relations in UML class diagram inherit?
Tutorial :How relations in UML class diagram inherit?
My question is, how do these relations inherit? For example, when ClassA is dependent on ClassB, will ClassC depend on ClassB? etc.
You're not asking a UML question, you're asking a more general question.
ClassC is a subclass of ClassA. In every programming language that implements inheritance, ClassC will have all the features of ClassA.
In a language that doesn't support inheritance, you must create the illusion of proper inheritance by assuring that all features of ClassA are also part of ClassC.
That's the definition of inheritance. Always and forever. Even in UML diagrams.
The simple answer is yes (and you should not need to look beyond that for most practical purpose).
The words generalization and inheritance are often used interchangeably, but there are actually two related but distinct concepts. Generalization is a taxonomic relationship among modeling elements. It describes what an element is. Inheritance is a mechanism for combining shared incremental descriptions to form a full description of an element. In most object-oriented systems, inheritance is based on generalization, but inheritance can be based on other concepts, such as the delegation pointer of the Self language. Basing the inheritance mechanism on the generalization relationship enables factoring and sharing of descriptions and polymorphic behavior. This is the approach taken by most object-oriented languages and by UML. But keep in mind that there are other approaches that could have been taken and that are used by some programming languages.
Conceptually, we can say that a Corporate Customer is a subtype of Customer if all instances of Corporate Customer are also, by definition, instances of Customer. A Corporate Customer is then a special kind of Customer.
The concept of generalization belongs to the conceptual, design level.
With a software perspective, the obvious interpretation is inheritance: The Corporate Customer is a subclass of Customer. In mainstream OO languages, the subclass inherits all the features of the superclass and may override any superclass methods.
At design level, there is a generalization relationship between the square and the rectangle.
It would be counterproductive to inherit the width and height of the Rectangle class in the Square class, which would require extra constraints to ensure that the same value is provided to a setter for the width and a setter for the height.
This is a case (somewhat edgy I admit) where you would not translate a generalization relationship to the use of inheritance at the implementation level.
Well, those were the days.
For example, when ClassA is dependent on ClassB, will ClassC depend on ClassB?