2

I'm trying to model some requirements and I saw some examples in the web with use cases generalization, but the UML 2.5 standard review doesn't say anything about generalization in Use Case Diagrams, or I can't find it.

So, is generalization supported by standards?

DuncanACoulter
  • 2,095
  • 2
  • 25
  • 38
gal007
  • 6,911
  • 8
  • 47
  • 70
  • How would you - formally - define generalization. It is very hard in my opinion. You can generalize nearly anything until there is not much to tell anymore... There are numerous discussion about whether a rectangle is a generalization of a square or the opposite (in mathematics, the relation is quite clear, in oo-design, it is most certainly not). – Willem Van Onsem Aug 26 '14 at 07:07
  • @CommuSoft: Why shouldn't it be clear in OO design that `Square` is a subtype of `Rectangle`? Of course, one can formally define generalization for specific categories of types. For instance, OWL does this for the generalization between classes (object types). – Gerd Wagner Aug 26 '14 at 08:22
  • @gwag: because of the simple reason that a rectangle has an additional field (and properties) which is against oo-design. I would also vote for Square extends Rectangle` https://news.ycombinator.com/item?id=822354 – Willem Van Onsem Aug 26 '14 at 08:37
  • 1
    @CommuSoft: you have a point as far as generic OO goes, but the question is specific to UML, where generalization is indeed formally defined. – Uffe Aug 26 '14 at 08:43
  • 1
    @CommuSoft: That's just a misunderstanding based on wrong modeling. The correct model is `Square` is a subtype of `Rectangle( width, height)` with an invariant attached to `Square` requiring that width = height. Subtyping doe not always imply adding properties, it can also mean adding constraints/invariants (this is called subtyping by `restriction` in XML Schema). – Gerd Wagner Aug 26 '14 at 08:47
  • @gwag: In (most) OO design, inheritance confers ALL properties of the supertype to the subtype. A `Rectangle` class might well have two methods `GetLongSideLength()` and `GetShortSideLength()`; these make no sense in a `Square` class which should only have a single `GetSideLength()`. Thus, the two classes should not be subtypes of one another (but possibly of an abstract `Shape` class). – Uffe Aug 26 '14 at 08:47
  • @Uffe: Not complying with the semantics of the geometrical concepts to be modeled would be poor modeling. The semantics is defined via the essential properties `width` and `height`, and not via some funny getters. – Gerd Wagner Aug 26 '14 at 08:55
  • @gwag: I agree `Square extends Rectangle` as noted before. Point is that people debate this (not with softspoken voice) on the internet. And thus it is not absolutely clear how one should design it. – Willem Van Onsem Aug 26 '14 at 09:35

4 Answers4

2

Tricky.

While the Generalization relationship is defined as going between two Classifiers, and a Use Case is itself a specialization of a Classifier, the semantics of the Generalization relationship are primarily focused on Features (eg Attributes). These are inherited, but relationships are not.

On the other hand, the UML specification itself includes an example of use case generalization (2.4.1 Superstructure, fig 16.7, p 609).

Back on the first hand, the same specification omits generalization in table 16.1, "Graphic nodes included in use case diagrams" (p 611-613), but does include the two main intra-use case relationships; Extend and Include.

On the other hand again, the same table includes Actor but excludes the Association between Actor and Use Case.

Sadly, the UML specification is in many respects a horrifying mess, and the 2.5 version is in part an attempt to rectify this.

On balance, I would say no - you can't generalize between use cases.

Uffe
  • 10,396
  • 1
  • 33
  • 40
  • I'm sorry, but I don't agree with this. – BobRodes Dec 09 '14 at 05:04
  • I strongly agree :-) 2.5 is definitely better than the previous versions. However, it's obvious (to me) that the document is created by techies while the UC part should have been written by people that sometimes deal with customers. Bittner/Spence would have been the right consultants here. – qwerty_so Sep 24 '19 at 13:16
  • Probably you should say _you should not_ rather than _you can't_. – qwerty_so Sep 24 '19 at 13:23
2

Since a UseCase is a Classifier, they can be generalized. The UML 2.5 spec contains an example of this in Fig. 18.11 on p. 686 (the "ATM Services" example).

Gerd Wagner
  • 5,481
  • 1
  • 22
  • 41
2

I don't know if use case generalization is "supported" by an official UML standard. But

So my conclusion is that use case generalization is supported just enough and practically you can use if you need it.

But more usual way to express that one use case is specialization of another use case is (IMO) through the <<extend>> relationship. See http://www.uml-diagrams.org/use-case-extend.html and http://www.batimes.com/articles/use-case-goals-scenarios-and-flows.html (and Wikipedia) for some more detailed discussion

xmojmr
  • 8,073
  • 5
  • 31
  • 54
  • 1
    Good answer. I will add though that while Sparx EA is IMO the most useful modelling tool out there, it is also one of the more lax in terms of how strictly it enforces the UML standard (which is one reason it is so useful). So what EA does or doesn't do is not a strong indication of what the standard says. – Uffe Aug 27 '14 at 07:51
  • @Uffe Good point. I really don't know what exactly standard says and actually I don't care too much and I thing that OP also does not need to care too much and that is why I decided to write an answer. My loose translation of the "is XY supported by standards?" is "is XY approved way to go?". A practical example where the standard is little bit behind approved way and still the approved way is the way to go is HTML5 which is now a recommendation but not approved standard and yet it is approved way to go within some [measurable limits](http://caniuse.com/). UML standard looks similar to me – xmojmr Aug 27 '14 at 15:41
  • For the record, generalization/specialization relationships are part of the UML spec. – BobRodes Dec 09 '14 at 04:41
  • Extend relationships are quite distinct from inheritance relationships, actually. For example, the specializations in the diagram in my answer couldn't substitute extends. Extends are much more common, to be sure, but they are not the same thing. – BobRodes Dec 09 '14 at 05:03
-1

As gwag has mentioned, generalization/specialization is indeed included in the use case spec. What's more, there are plenty of situations where it is useful. Here's an example, from this page:

BobRodes
  • 5,990
  • 2
  • 24
  • 26
  • No, that's just a techie view. Wether to send a message via MODBUS (whatever that is) or TCP/IP is a technical implementation detail. – qwerty_so Sep 24 '19 at 13:20
  • @qwerty_so Since you don't know what MODBUS is, you don't really know whether it is only a technical implementation detail. In particular (after looking some things up), it seems that a navigator communicates via two discrete groups of devices that use one or the other of these protocols. So these two use cases are probably better named "Send via MODBUS device" and "Send via TCP/IP device." (But that's kind of long.) As such, the process of communicating via MODBUS devices is distinct from the process of communicating via TCP/IP devices in a more than technical sense. – BobRodes Oct 08 '19 at 08:09
  • I looked up MODBUS and (as my feeling proves right) it is just another protocol. So a technical detail as stated. Exposing this in a level where Aircrew and Navigator is involved is, sorry, insane. The Navigator just does not care where a pigeon or a cable is used to send the message. He only cares about the contents! And he wants it to appear secured. – qwerty_so Oct 08 '19 at 10:15
  • @qwerty_so A reasonable point of view. It may be a bad example. But the underlying point that generalization/specialization of actors and use cases is supported in use case diagrams remains valid. – BobRodes Oct 09 '19 at 00:34
  • Well, yes. UML **allows** it, but it does not make real sense. To cite a former German comedian: Life without a pug is possible - but meaningless. I'd says: UML with generalized UC is possible - but meaningless. I'm on Uffe's side. – qwerty_so Oct 09 '19 at 08:46
  • @qwerty_so I'm unconvinced. Given that a use case defines an activity, which can be modeled in an activity diagram. Suppose, then, that we have a use case that involves paying a bill. There are two ways to pay the bill, one with cash and one with credit. I don't see these as implementation details, because the actor does something different in each -- their activity diagrams would differ. And yet, there are common activities associated with each, say "get wallet." That suggests a generalized use case "pay bill," with two specialized "cash" and "credit" use cases that inherit from it. Thoughts? – BobRodes Oct 09 '19 at 21:05
  • What you're doing is functional decomposition. The use case (the added value) is to get something sold. The difficulty is to not focus but to look at a greater picture. I recommend reading Bittner/Spence about UCs. – qwerty_so Oct 10 '19 at 05:56