If my class (interface) has no fields, should I leave white space to make it obvious that there is to state?
With whitespace:
No whitespace:
I'd use with whitespace. I've seen some examples on the web like this (https://www.ibm.com/developerworks/rational/library/content/RationalEdge/sep04/bell/). In Figure 10, The Person interface has no methods, but the space to put methods is present.
You can do it both ways. Compartments can be set ad libitum. Use whatever fits your taste best. You should however setup modeling rules that constraint the use of compartments to whatever you think might be the best. The UML spec e.g. uses this on p. 16:
Within such a diagram, all of the metaclasses described in that clause are depicted with their attribute compartments, while metaclasses whose definition appears in another clause are depicted with just their headers and no compartments.
And some more examples on pp. 193.
P.S. I have just checked what EA shows in case and it will not show an empty compartment but completely suppress it.
Related
I'm wandering whether the following use case diagram is correct because I'm not sure if such notations are possible: something is going from extending use case, and this notation of this transition. I haven't found any information regarding such cases and would be glad if someone could help me.
To express that a (partial or secondary) use case is used only under certain cercumstances and you want to express them explicitly, you can use extension points. An extension points defines explicitly the conditions when the Main use case is extended. In reality, this Feature of uml is Quitte rarely used. Because it adds a high degree of concreteness to the abstrakt Level of use cases.
In your example you are using the wrong kind of relation. You are showing an extend relation, which expressed that a Stereotype can be applied to a meta type. Instead you should use an extends relation, which has a dashed line and on open arrow head.
I'm very new to UML, especially use case diagrams. I attempted to draw a use case diagram for my application which includes a renter, a seller, and a general user. My renter and seller extend general user. I am having trouble with includes and extends. For example, When you view an office space, you can also see the reviews for it at the bottom of the page. As well as when a renter wants to write a review, he/she must do this on the view office space page. I am not sure if this is an extends or an include. Please correct me if I am wrong with any of my arrow directions. Also, is it okay to say that Renter and Seller include logging in?
As Jim states: I/E are for UCs, not for Actors. I assume you meant a generalization here, so both inherit from General User.
Some further observations:
Use verb-substantive for UCs titles
Think of the "use" in use cases. IOW: the added value. If you don't find it's added value, then it's no use case.
Avoid I/E in general. They often indicate that you try to use functional decomposition which is not the aim of a UC synthesis.
The relation you draw between the UCs is wrong in any case. There is no relation which has a filled triangle and is dotted. You probably meant to use some <<include>> dependency (with an open arrow). But as said above: avoid it. Just create an association to the actors. It's sufficient to just draw one between Reviews and General User as Renter will inherit the relation.
Login/out are no UCs (no added value). The are constraints to other UC (write {must be logged in} and attach to the connector)
You generally should not model login use cases, as they don't directly help the user accomplish anything he or she cares about.
Includes and extends are relationships between use use cases, not actors. The UML 2.5 specification says:
An extension is:
A relationship from an extending UseCase to an extended UseCase that specifies how and when the behavior defined in the extending UseCase can be inserted into the behavior defined in the extended UseCase.
An include is:
An Include relationship specifies that a UseCase contains the behavior defined in another UseCase.
A generalization / specialization relationship between actors is perfectly fine. That's just a generalization arrow. (e.g., a solid line with a hollow arrow head.)
How do I create an abstract use case in enterprise architect 10?
Edit:
Here is an example:
How do I achieve this in Enterprise Architect?
Stereotyping the use case as "abstract" does not change the font face.
I'm not asking how to change the font manually. I was expecting that if a use case is stereotyped as "abstract" then its title font face would automatically be changed to italic. But that does not seem to be the case.
Go to the properties window (not the dialog that pops up when you double click on the element, the windows default posion is in the lower-left corner).
In the "Advanced" section set "Abstract" to "True".
Regardless of the type of element, "abstractness" is not expressed as a stereotype in EA, so that wouldn't work for classes either. Instead, there is an "abstract" checkbox in the element's Properties dialog. You'll find it on the Details page if you open the dialog for a class.
The same dialog for a use case, however, does not include the "abstract" checkbox. However, the underlying data model allows any element to be abstract, including use cases.
Leaving aside the correctness or otherwise of modelling abstract use cases in favor of answering the actual question, there are two ways to achieve an abstract use case in EA. Both are "proper" in that they result in use cases with the appropriate "abstract" property set, as opposed to making purely cosmetic changes in the font or similar.
Use cases made abstract in either of these ways will be displayed with an italic font automatically, they can be distinguished in searches and generated reports, etc.
Method 1: element properties window
In the Element Properties Window (not the dialog but the one you open in Element menu), you can set the "abstract" property under the Advanced branch.
Method 2: use a script
Here's a VB script snippet which makes a single use case abstract.
if (theElement.Type = "UseCase") then
theElement.Abstract = 1
theElement.Update()
end if
If you place that in a diagram or object browser script you can easily make a use case abstract. You'll probably want to modify it to make it a toggle rather than one-way, but you get the idea.
This can be useful if you've already created a number of concrete use cases and want to make them abstract.
It is possible, but useless, and and style both in UML and OOP
If your client insists on the structure, you can show variations of some behaviour by extends and include stereotypes. And some of the variations can have a note that says, that this variation will be never really realized. This is semantically equivalent to your abstract use case. ...And the uselessness of the thing is obvious, too.
You can set Abstrect property directly, as is shown in a neighbouring answer. But it doesn't add to usefullness.
More reasons not to use "abstract" :
What does being abstract means? It means, that this very structure will be never realized by itself, and will only provide some common features to other, concrete structures. I.e., it is setting the way of REALIZATION, the inner construction of your system. And you should NOT solve problems of realization on UC diagrams, they are merely formal way of setting the task you are solving. You should not mix setting the task and solving it.
In technical way, being abstract is a structural piece of information. Use case diagram is a behavioral diagram. You CAN use structural elements borrowed from other diagrams in it, though. For example, abstract classes. But it is for exceptional use, not standard one. For example, you are solving the task and (alas!) you have already some SW/HW rigidly set due to licenses or politics. It is not good, but it can happen. But use case itself if pure behavioral element and you can't simply say it is abstract.
"abstract" is a word used in some languages, but not in all OOP languages. You shouldn't set the language in the UC diagram.
Use case shows behaviour, and will be realized first rather by interface than by class. And all interfaces already are abstract.
I have a CU that extends another CU, let's say: Add inventory extends Add product, so in one product interface I need to use fields from inventory CU, how I can described this in a CU?
"Extends" means that during the "execution" of the extended UC, execution of the extending UC has been voluntarily invoked by an actor. Each UC is described by several scenarios. Scenario is decribed as an ordered sequence of "steps".
You have to specify so called extension points - steps in the scenario(s) of the extended use case, in which the Actor can invoke the extending UC's execution. It can be a single step or a range...
You can think of the extension point as of a method with parameters, tmplemented in the extending UC and invoked by the extended UC. These parameters could be these fields, you need to "pass" to another interface.
In my projects I always "back up" the my case model with the domain model (class diagram) and use elements of it in the specification of the UCs (preconditions, postconditions, scenarios, extension points).
UPDATE (after the comment)
UML does not define the concrete format of the use case specification, it only defines the concepts and their semantic meaning. A UC can have so called Behavior, can extend another one (or be extended), has Extension points.
The way you define Behavior and Extension points are your own choice.
So, in my example:
Behavior of both UC is defined as a textual sequence of steps, as performed by System or User (alternative is a state machine, activity diagram, even user interface prototype)
Extension Point is defined as a step in the sequence and additionally described by this "method" signature, to illustrate the exchanged information
Remember that UCs show INTERACTIONS beetween the System and the outside world. For them is the System kind of black box. Conceptual model I've used here is therefore NOT a DB or system design, but rather a conceptual, implementation-agnostic view on the entities used by the app. They can even be mapped on 2 different systems on the implementation level!
Relationships between the UCs similarly exist purely on the user-system interaction level of abstraction, and DO NOT BY ANY MEANS reflect some internal system dependencies!
(note added after Gangnus's comment)
(Scenarios and concepts are fully invented for the example sake)
UML standard 2.5, p.680, definition:
An Extend is a relationship from an extending UseCase (the extension)
to an extended UseCase (the extendedCase) that specifies how and when
the behavior defined in the extending UseCase can be inserted into the
behavior defined in the extended UseCase. The extension takes place at
one or more specific extension points defined in the extended UseCase.
Extend is intended to be used when there is some additional behavior
that should be added, possibly conditionally, to the behavior defined
in a UseCase.
I wouldn't call what you are describing an extension. Inventory instance is a container that has Product instances as items. So, Add Inventory is a behaviour that depends on existent products, but not on ways of their adding. So, if you use correct OOP strategy, Add Inventory is absolutely independent on Add Product behaviour. They are both independent behaviours.
Yes, they work on structures, that are dependent and associated, but structures mostly are described in other diagrams. So, normally, these two behaviours are two different independent UCs.
On the other hand, according to standard, you can mix elements of different diagrams, and if you MUST show that intermediate dependency on UC diagram, you can draw there appropriate classes(Product and Inventory), connected by an association. Your use cases will be connected to these classes by arrow "dependency" - - - - - - >
Notice, that Use Case "add Product" and method "addProduct" in some class are absolutely different things. The first is behaviour, described in manual, with participation of user, and the second is a piece of code. The first is the task and the test for the second - that is a realization. So, beware, put classes into Use Cases only if you understand what you are doing VERY WELL, it is not the way for starters. Minimally, reread the Use Cases chapter of the UML standard before. Personally, I would show classes in separate classes diagram here. It is much more easy way.
I've taken the course Object Oriented System and Design at Stockholm University. I had to hand in an extra assignment where I had to create a UML Class Diagram reflecting a web site that sold cars (this is not a thread where I'm asking you to do my homework). This is what I handed in:
The teacher said that "this isn't how you use attributes" and seems reluctant to explaining what I should have done differently. It's all in Swedish but I think that the main points are clear regardless of language.
My question is: How should this have been modeled differently? I have aggregation for some objects, enums because the website had a limited amount of attributes for some classes.
Any help is greatly appreciated.
Kind regards,
Hugo
I see some problems in your diagram:
I believe you have some enumerations in your diagram that are not defined properly. An enumeration should look like this.
You define attributes in addition to aggregation (e.g. the Bil has a aggregation relation to this SäkerhetsTilägg, and additionally defines an attribute säkerhet. You should either use a relation or an attribute, see here.
While we are at this, the multiplicities are somewhat confusing. You say that Bil can have any number of SäkerhetsTilägg, while the attribute säkerhet holds exactly one SäkerhetsTilägg.
Afaik, you have to define the visibility of attributes and methods (like +, - etc).
It looks to me like you've got your Enumerations modeled as Classes. Even though visually an Enumeration looks like a Class with an <> stereotype, it's really a different thing altogether and it has EnumerationLiterals in the compartment when Attributes would be for a Class.
In ArgoUML you can create an Enumeration using the fourth button from the right on the toolbar. It's a dropdown menu which defaults to creating a new Datatype, but if you pull it down and select the green rectangle, it'll create an Enumeration. Create your Enumerations first and they'll be available for you to select as the type for your Attributes.
The final result should look like this: