1

Can someone give me an example of when is better to use State Diagram and when Class Diagram. Tnx in advance!

For what type of software system would you use state machine diagrams to model functional requirements? For what type of software system is data modeling via UML class diagrams suitable?

3 Answers 3

3

A class diagram shows classes in their relation and their properties and methods.

A state diagram visualizes a class's states and how they can change over time.

In both cases you are talking about diagrams which are only a window into the model. The class relations define how the single classes relate to each other. A state machine can be defined for each class to show its states. In embedded systems you use state machines almost all the time but there are also state machines for business applications (you can do this if that).

1

This question reveals a very common misunderstanding. There are only thirteen types of diagram in UML. They're not used to describe different types of system, but to describe different aspects of the system you are documenting. Which you pick in any given situation is more a question of style, what you want to emphasize.

It is better to use state diagrams if you want to focus on how the system can go into different states in response to various events. Activity diagrams are better if you want to focus on activities being carried out in some order, sequence diagrams are better if you want to show messages being sent between entities.

The above are all types of diagram which show behaviour. Class diagrams are a different type of beast altogether, and show how structures of things fit together (as do package diagrams and component diagrams).

It might be worth pointing out that while UML does not include a "requirement" element type, the related modelling language SysML does. If you want to express a number of functional requirements on the form "the system shall" in a model, SysML is a better fit.

1
  • Not 13. there are 14 types diagrams in UML Jul 14, 2016 at 14:57
0

A state diagram shows the behavior of the class. A class model shows the relationship between two or more classes. It includes its properties/attributes... A state is an allowable sequence of changes of objects of a class model.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.