Generate Source Code's questions. (#1564)

I have four questions to ask.

Question 1.

The C # Generate Source Code.

What the differ protocol state machine and state machine ?

Question 2.

why the sequence diagram is not Generate to Java?

Question 3.

Which Diagram can Generate to Java?

Question 4.

Which Diagram can Generate to Python?

Question 5.

Can you about to me.

Which Diagram can Generate Relative to Program language?

3 October 2018 18:17:24
15 October 2018 10:34:14
Requested by
windows 10
Solved in

Dusan Rodina - 3 October 2018 21:42:40

Q1) UML protocol state machines are used to model a usage protocol or stages of a classifier. It defines which operations may be executed in which state of the classifier and which conditions must be fulfilled.

In generated source code you can define the code which should be executed when enter and exit a specific state or what to do when a state is active.

The State Machine template is for behavior state machines.

The type of state machine diagram can be set in the Diagram Properties dialog - right click somewhere on free space in a diagram, choose Properties from the context menu, then choose State Machine tab and in the Type group choose Behavior or Protocol type.

In a behavior state machine, you should use Transition tool for transitions and for protocol state machine, you should use Protocal Transition. If you use the context bar (under a selected element) to add new states, the correct transition type is chosen automatically according the state machine type.

The correct way how to create a new protocol state machine and generate the source code for it is:

1. Create a class in a class diagram and select it (or select an existing class) - the class should have some operations

2. Right click on the class and choose Add Nested Diagram

3. Choose State Machine diagram in New Diagram dialog and type its name

4. Right click on free space in this state machine diagram

5. Choose Properties

6. Open State Machine tab

7. Change the state machine type to Protocol

8. Add states and transitions to your diagram

9. In Ribbon, choose Process tab and click on Source Code in Generation group

10. Check your state machine diagram in the project tree in Source Code Generation dialog

11. Change language to C#

12. Change template to ProtocolStateMachine

13. Click on Generate

14. The source code for your state machine should be generated

Q2) Sequence diagram is not yet supported by source code generation. It will be added in one of next versions.

Q3) Q4) Source code for Java and Python can be generated from Class Diagrams.

Q5) I am not sure whether I understand this question correctly. UML class diagram can be generated to any supported language. The source code generation processes also relations - aggregations, compositions, generatlizations.

In general, a source code (or script) may be generated from these diagrams: UML class diagram, UML state machine diagram (C#), Entity-Relationship diagram (SQL, C# NHibernate)

Software Ideas Modeler implements a template language which allows you to edit existing templates or to create any custom template.

More about templates:

In case of any other questions, feel free to let me know.

Your Name:
You can use these formatting tags: [b]bold[/b] [i]italic[/i] [u]underline[/u] [url][/url] [code]some code[/code] [quote]quoted text[/quote] [list]one list item per line[/list]