I'm trying to build a state diagram derived from the class diagram for the Support Manager Class.
Here is the class diagram (reputation <10 so can only provide link):
http://i.imgur.com/3wFO9Gu.png
This is the state diagram that I have constructed so far: http://i.imgur.com/vBTyTLX.png
I'm not sure if this is correct. But the state diagram should represent the Manager class and the manager class is supposed to:
Allocate 'resource' to employees
Be able to update the resource to employees
View the outstanding job for an employee
allocate a technician to a job
update the system information
notify employee that the job has been complete - (technician fixes
problem and the job is confirmed by manager).
Is this possible to represent on one state diagram? Or would this require several? Is the diagram correct in the representation of how the manager deals with a resource problem raised by an employee?
You can't derive state diagram from a class diagram. For behaviour is not defined by structure.
But you can create a state diagram for explanation in addition to a class diagram.
Principally your state diagram is OK. But:
you have obvious errors in its lower part - you are doubling the choice confirm/reject there.
It is a STATE diagram? Where are states? You have mixed actions (arrows) and states (rounded rectangles) so, that you have only actions. If you want to describe actions instead of states, you really need activity diagram.
You can create a state diagram for modelling Manager behaviour. But it has sense only if you are thinking of it in terms of states and events/actions.
for me what you want to represent seem to be an Activity diagram more than a State diagram because, for me, you describe more a working process than states.
It should be feasible to represent your behavior in one unique diagram (if it is still comprehensible).
You are the only which cant tell if your representation is fine, but maybe could you add link (call) to your method!?
The state diagram is definitelly not the adequate tool to show Manager's activity. The reasons are many, I'll give you just one - Manager can have several "threads" of the "workflow" represented by this state diagram - one job can be in the "pending" state, another in "confirmation", etc.
Therefore this workflow would rather define the class "Job", than the Manager. You could review the multiplications on this class, as not all liks are established on the Job class creation.
The responsabilities of the Manager (that you listed) could be modelled by methods on the class and their sequenceby an activity diagram.
Related
I want to understand a class diagram more fully and I am finding lots of conflicting information.
My first question is, what is the difference between class diagram and ERD? Not necessarily in look, but in classification. e.g. I have read that a class diagram is a type of ERD and I have read that a class diagram and an ERD are two different things.
My second question is around how the class diagram should look, I was given a basic tutorial on how to create a class diagram and I was taught that each class should be connected with a single line, with an arrow that looks like a 'Play' symbol (example 1 in the attached image)
But since doing some research into it, I am finding lots of examples where different connectors are used to denote association, aggregation, composition, inheritance etc. (example 2 in the attached image)
As mine is more simplistic, just showing the relationship and the multiplicities, does that mean that I have just learned a more basic version of class diagram and the extra connectors are an advanced step?
Or are they both something different?
Thanks for your help
Holly
First of all, welcome to Stack Overflow!
A class diagram is a type of static structure diagram that describes the structure of a system by showing the system's classes, their attributes, operations (or methods), and the relationships among objects. Wiki link
An entity relationship diagram (ERD) shows the relationships of entity sets stored in a database. Link
Therefore the answer to your question of "what is the difference between class diagram and ERD"?
The class diagram has nothing to do with fact how the classes are persisted in the data layer. It shows only the logical relationship between classes and the properties of the classes. While the ERD diagram illustrates the logical structure of database; what the database tables, table-column, primary keys, foreign keys, etc. are, and last but not least the relationships between database tables.
As for the question "Is this just a more advanced version of class diagram? Or a more updated version?":
There are cases when the ERD diagram can look similar to the corresponding class diagram, but the persistence data model can be way different from the class (domain) model. Furthermore a class diagram has no any information about how a class is persisted in the database - as I've already mentioned -, therefore an ERD has other kind of information than a class diagram.
As for the notations you linked:
A proper class diagram contains notations like in the second link. An example is the following diagram:
For more info what those arrows mean, click here for the corresponding SO answer.
What you are taught about how to make a class diagram (like at the first link you shown), can also be useful but it is a customized class diagram rather than an proper class diagram following the UML standards and notations because:
I find it strange that the arrow is not on the line itself
There is a shared ownership relationship (aggregation) between Customer and Vehicle. It means that a Customer can have (own) a Vehicle but the Vehicle can still exist as its own, without a Customer. This relationship can be represented with the aggregation notation. (See arrow 5a, or the class diagram below)
I find it also strange that a vehicle can have multiple Customers, as you notated with "0..*". But of course it is possible, since I do not know what kind of domain you try to model with the diagram...I made an UML diagram with proper signs, check this out:
Summing up, it is wise to follow the UML standards and conventions, since it is widely accepted and known so the information can be exchanged as efficient as possible, without misunderstanding.
Do you have any idea how to reuse an interaction in more than one sequence diagram in Enterprise Architect?
In this case, I'd like to reuse the interaction ServiceX in different sequence diagram.
You must not do that. A message is only part of the diagram it is placed on and used in the very context you show on that specific SD. The same applies for the life lines. They are all instances of classes and never re-used in other SDs.
Actually you derive the message from an operation defined in the class that instantiates your object. Just choose the right one from the message drop down.
As you can see, Class1 is the classifier of Object1 and its operation is available in the dropdown.
How can I associate messages(operation calls) in a sequence diagram to its implementation(method)as an activity diagram?
I am using Papyrus for modelling.
There is an indirect relationship possible in this case.
A method is typically defined in a class from a class diagram.
The same method is specified using an activity diagram.
The invocation of the method can be shown on a sequence diagram.
Class diagram gives kind of a structural back-up the the rest of the diagrams, and is highely recommendable to make one (if you don't have it already).
The messaging in a sequence diagram are meant to become method invocations upon classes of objects. Activity diagrams are meant to be like a flow chart of the business processes. The former will be very specific and detailed; the latter will be more generic and not so specific.
While they can be coincidentally related if you choose to model that way, since they are not by UML standards to be that directly related I don't think you'll find tooling that will do this for you.
You can read more here:
UML Activity Diagram tutorial
UML Sequence Diagram tutorial
What is the best UML diagram type to use when trying to show how a class' behavior flows from one method to another?
I am trying to diagram existing code and the behavior I am looking at primarily involves private method calls, with a few calls to static objects outside the class. I don't feel that a sequence diagram would give the best detail in this case since the class in question doesn't interact with any other classes except for the very few static calls mentioned earlier.
What would fit best in this situation?
According to the UML Superstructure (http://www.omg.org/spec/UML), in the UML two kind of behaviors exist: emergent behaviors and executing behaviors.
An executing behavior is performed by an object (its host) and is the description of the behavior of this object.
An executing behavior is directly caused by the invocation of a behavioral feature of that object or by its creation. In either case, it is a consequence of the execution of an action by some related object. A behavior has access to the structural features of its host object. Objects that may host behaviors are specified by the concrete subtypes of the BehavioredClassifier metaclass.
Emergent behavior results from the interaction of one or more participant objects. If the participating objects are parts of a larger composite object, an emerging behavior can be seen as indirectly describing the behavior of the container object also. Nevertheless, an emergent behavior can result from the executing behaviors of the participant objects.
You can model behaviors by means of Activities or Interactions (actually you may also use state machines and use cases). Activities are more adapt to model executing behaviors while Interactions to model emergent behaviors.
Now if your class has many parts and its behavior you want to model consists in a "complex" interaction of its parts then probably an interaction diagram (sequence) may be the right choice. Otherwise, if the behavior you need to model, consists of a sequence of atomic actions an activity may be better. Consider in UML there is a specific actions to represent the invokation of a method (CallOperationAction) which takes as input pin the object reference you can retrieve by means of a dedicated action (ReadSelfAction). There is also an action to read an object attribute (ReadStructuralFeatureAction).
Also check the Foundational for Executable UML Models (FUML) http://www.omg.org/spec/FUML
While all of the previous answers are correct, I would like to add the option of using a State-Machine to define the behavior of the class. State machines allow you to show what is the current state of the class and how the state of the class changes as methods are called or events are received. Since you state that you are mostly modeling one class, I think the most important thing to show is what can be done (what method calls can be called) depending on the current state and how these method calls affect the state of the class. One think I really like about state machines is that they have relatively well defined semantics and also have ways to show information at different levels using composite and orthogonal states.
Broadly you have 2 choices (per #Silli's answer): sequence or activity diagram. I would probably have suggested sequence diag as first choice, however you say you don't think that's appropriate. Could you elaborate why?
Perhaps it's conditional logic? If so an activity diagram may be the better choice. It has more intuitive syntax for showing control flow than a sequence diagram. You could also show the static objects in separate swimlanes - so clearly differentiating calls to external objects. You can also illustrate parallel behaviour if that's relevant to you. Some good examples here if it helps.
hth.
I would recommend collaboration diagram (UML 1.x) renamed to Communication diagram (UML 2.x).
This may be better than sequence diagram, better because it may be more readable in your case.
A Communication diagram models the interactions between objects or parts in terms of sequenced messages. Communication diagrams represent a combination of information taken from Class, Sequence, and Use Case Diagrams describing both the static structure and dynamic behavior of a system.
http://en.wikipedia.org/wiki/Communication_diagram
Allowing a store whether a product is available in the stock of another store partner, the latter may either accept or reject the request, in all cases the applicant is informed of réponse.
I want to implement a diagram class.
Now I have a class product, and a class list of collections of products.
I don't know how to represent a class of operation "request for product availability.
Is there a design pattern corresponding to this situation?
or a simple example of class diagram would be welcome.
I'm assuming that you are talking about representing your design in some suitable diagram, in which case you need to study some "Modeling Language" - probably the most widely used today being UML. This is a big topic, but you could start here.
Now diagrams such as these are really only useful when your design reaches some level of complexity. Here you are thinking about just a couple of classes and one method a diagram won't help much. So maybe you are doing this as a learning exercise?
You probably need both a Class diagram and a Sequence Diagram.
The major thing you seem to be confused about is how to represent Operations, they are just listed against the class. So your Store class would have an operation transferInventory().
So your class diagram is very simple only a couple of classes Store, Product. But the interesting thing is that your Sequence diagram will show that you have more than one instance of the Store class: StoreA, StoreB and the instances communicate with each other.
One thing you haven't talked about: how did StoreA know that StoreB exists? Why did it choose that Store to ask for a product. There's some additional classes here such as a registry of Stores. I would be much more interested in figuring out that than in drawing diagrams.