Understanding why the extends arrow points in the opposite direction - uml

In class diagrams I typically see something like ClassA extends ClassB where the arrow head points to ClassA. Example, here. This has always confused me. Why is the arrow head not pointing to ClassB?

UML is simply used wrong in those diagrams. The arrow head must be a triangle (not an open one) it must point into the other direction and it is called realizes not implements. So if I did not entirely misinterpret the diagrams the author (of the diagram or of the software which created them) simply did not know how to use UML correctly.
In this diagram (just found by googling) you can see a correct visualization of a class "SearchService" realizing (implementing) the interface "SiteSearch".
In the next diagram several classes are generalized by (specialize, extend) the class "Account".
On this site you can get an overview (looks correct on the first glance). If you want to be sure you should look into the specification (find pdf download there).

I think the confusion here crops up out of the variations in the way people relate to the subtleties of English grammar.
Some people may be inclined to complete the "inconvenient" but UML-standard token "extend" as "extends", while others will complete it as "extended" when viewing or designing a diagram. Hence the differences in interpretation.

Related

UML abstract classes?

So I'm currently self-teaching myself UML and I took an online quiz to help strengthen my understanding of it.
One of the questions asked:
How do you model the following situation with a UML2 class diagram:
"There are multiple different bird species, e.g. blackbird, thrush,
and starling."
And two available options were:
The diagram on the top is correct (and I understand why), however, the diagram on the bottom is incorrect. Why is this? Since the three birds inherit from the abstract class bird and conform to any abstract methods, aren't they all birds?
There's two possible answers to this I think:
The top is incorrect logically since you can't create an instance of a Bird on its own. Bird is an abstract classification of all bird species. You can only create Thrushes, Starlings and Blackbirds. I'm not sure what a Bird instance would look like, but it would be supernatural.
The bottom is incorrect syntactically because the abstract constraint should be applied after the class's name and type.
Personally I think I'd let the #2 one go (it's a mistake, who cares?) and focus on #1 which is, if I was in the business of birds, more important.
The UML 2.5 spec says on p. 98
The isAbstract property of Classifier, when true, specifies that the Classifier is abstract, i.e., has no direct instances: every instance of the abstract Classifier shall be an instance of one of its specializations.
So whether or not Bird is adorned with the keyword abstract results in the restriction of being able to not/instantiate it. If you need a Bird instance you leave it away. If you want to create an animal index you will probably have the abstract Bird which tells what you need to basically include in a bird's description. But you don't describe it by itself.
In your case, both diagrams are "correct" in general. It just depends on the context you did not explain properly. You can fulfill the requirement with both since there is no requirement that you may not instantiate Bird.
The requirement in the quiz says:
There are multiple different bird species, e.g. blackbird, thrush, and starling
But it does not says anything about what information you should hold about the bird species. So my first assumption is that the user would only be interested in the type.
The UML diagram:
is a valid solution for this requirement.
The two options in your quiz are also both valid solutions depending on how you look at the requirement. The requirement gave three examples which are all modelled explicitly in both solutions. "e.g." means there could be other birds and this fact is better described with the first solution. In the second solution you can have no instances of "Bird" that are not in the list of examples.
But this solution would only make sense if you could have some attributes and operations which are not shown - IMHO the minimum would be to keep track of the bird type - it is very awkward to retrieve this from the class name in most implementation environments.
Personally I do not think it is a good way to explain inheritance with such examples as in your quiz. Inheritance is costly in implementation (e.g. in most programming languages you end up with separate source code files per inherited class) and this cost should give you a certain benefit. This is mostly the case when the things to be depicted differ in theie attributes and behavior and you need different implementations. "Blackbird" and "Bluebird" might differ only in color (the color attribute is the discriminator). IMHO in this case it is better to have:
than

Class diagram to sequence diagram

I have a very strange exercise from school and I can't figure it out. I am supposed to change this class diagram (shown on picture) to sequence diagram. But it just doesn't make sense for me as long as it seems that this picture describes just one class.
As commented you can not really convert it, just invent an example. Since it looks like this is a Facade implementation, a good guess would be the following:
You can see that calls to the Facade are forwarded to the subsystems.

"Pointer" to class to shorten class diagram

Learning UML, I'm facing a problem with the arrows to classes.
For example, I have this diagram:
As you can see, it's kind of a mess. How is the notation to "reference" a class to another part of the diagram, so I can avoid drawing the arrows? I would like it to be like the following diagram, but keeping the information about the inheritance of the classes.
Any information or alternative will be helpful.
If you use newly done UML tools you should be able when you move the classifier and see the link to move at the same time.
I mean you click on the classifier in order to select it and then move slowly with the mouse

How to mark classes as Obsolete on UML

I have a few classes on my UML diagram which should not be used, but still available.
Is there any way to mark these classes as obsolete?
I've seen <> notation somewhere, but can not find how to use it in MS Visio 2003.
And another question. Should these classes be on UML diagram at all? I can imagine answer on this question would be on "per case" basis, but I'm interested in hearing general opinions. And if you put obsolete classes on your UML diagrams, why you did it? or why not?
Thanks!
It's not clear to me what you mean by " should not be used, but still available.". If they need to stay in the diagram but you want to visualize that they are now obsolete you can create a new stereotype <> and use it to annotate the obsolete classes.
If you don't really need them in the diagram then use a version control system for models as duffymo suggested. A list of version control tools for modeling elements can be founde here
I think if you're going to take the time to update the UML, the best idea is to remove it from the model. Leaving a bunch of "obsolete" diagram elements hanging around makes as much sense as keeping commented code in a version control system. Let the version control system manage the history.
I think that your model should include all your project and then you extract views from your model. If a class is not having any value in a specific view then this class should be removed from your class diagram view diagram but not from your model.
If you want to keep this class in your diagram then you can add a small comment (usually yellow square) or change the color of the class. I usually use green for class and then change the color to grey/green almost invisible but still visible color for non strategic classes.
Hope this help.

Structure and behavior in UML

I had some questions regarding the structure and behavior of a model, using UML, and the relationship between the two :
Did you find any limitations for UML regarding the specification or understanding of the relationship between structure and behavior?
I was wondering if you have any practical ideas of how one can optimize the relationship between structure and behavior, using UML.
Do you know any UML tools that help understand better this relationship or represent it much easier?
Thanks
Yes:
A sequence diagram is readable at a high level, showing how a transaction involves a few components; but it's not good (not readable) at the detailed level, showing how a transaction involves dozens of methods (method A calls method B, which gets data from methods D and E, and then invokes method F, etc.).
Looking at a class diagram, you might see a based class with several subclasses; this tells you nearly nothing about the behaviour of the classes (it only tells you that they may have some behaviour in common, or at least a common API, plus some individual behaior that's unique to each subclass).
That's a big question. A quick answer is, "Attach text notes to the objects: diagrams aren't sufficient without descriptive text."
No, I don't really; a UML tool help you create UML diagrams (and generate code from the diagrams), but it's up to you how you use it. There was a neat product described in the book titled Real-Time Object-Oriented Modeling (1994) which was an executable model, i.e. the model itself had behaviour, but I know of no UML tool quite like that. The closest I know of is being able to "round trip" between the model and code (i.e. generate code from the model, and the model from code).
Sounds like a homework problem. Wiki can tell you all about UML.
The limitations of UML are the same as any form of communication. The simpler your language, the fewer things you can communicate and the clearer your communications will become. A shape like a square or circle identifies a structure, a line indicates relationship, an arrow indicates movement, or flow. You could enhance this by defining the meaning of other properties, like direction, boldness, color, number count, different shapes. You could incorporate multimedia layers like audio or video, motion, tooltips- but now we're not talking about UML anymore.
My favorite UML tools are a whiteboard and some dry erase markers.
I think that things have changed, regarding UML's usefulness to melculetz.
In Visual Studio 2010, I can define an association relationship, that will generate composite classes. I can specify the multiplicity and class qualifiers. I can also generate classes from the model.
Presently, I am attempting to visually model the phases of a system, in order to visually define the methods for a state-machine object. That is my attempt to integrate structure and behaviour. Check my blog to see how I get on.
Class Analyser visually expresses the behaviour of class objects. Limitation removed.
I think that the answer is to turn your development methods towards MDA. You will generate more classes, but the payoff is in terms of manageability and re-use (where you template your efforts).
I am still working through my model but, I find VS2010 promises good tools for managing the development process. I have yet to investigate UI modelling, but have heard the rumours. I may have it all wrong but I think that, by working with Lightswitch, I may be able to model the UI also.
UML allows you to specify the signature of a method, and group methods into classes, but it says nothing at all about what code you use as implementation. If that's what you mean by "behavior", I don't think UML addresses it at all at the class level.
It's even worse at the UI level. My impression of UML is that it's woefully inadequate for specifying UIs.
I think the effort required to embed everything into UML is greater than or equal to coding the application, with the added burdens of UML tools being poor IDEs and inability to prove correctness of UML the way you can with unit testing.
UML is way oversold, IMO. I consider it a convenient notation for informal communication between developers, nothing more. It has never been and never will be the object oriented equivalent of engineering drawings.

Resources