Enterprise Architect - How to create classes from sequence diagrams? - class

I have experience with StarUML and Jumli. At my current company we have a Professional license for EA 9.2.
When I design a program, I start with creating Use Cases. Then from every Use Case, I create a Sequence Diagram. And from the Sequence Diagrams, almost every Lifeline-object will become a class (and all messages will become a method). With StarUML and Jumli this wasn't a problem.
But I cannot find a way in EA to convert the Lifeline objects into classes.
I tried to read the help from Sparx, but to me it is not really helpful. Their 'tutorial' is not a tutorial, but actually just another help file with lots of blah blah.
Can anyone tell me how to do this? Or are there any really helpful links?

It IS possible, but only in one a bit hidden way. First I'll tell you about the alternative ways:
you have a conceptual error here. Timelines in Sequence diagram are not classes, but objects. So, they can't become classes.
Of course, a tool could have a function to create a class according to an object, as VP UML has. Obviously, EA has not such feature.
On the contrary, it is not a problem to drop a class on the sequence diagram to become a timeline. But EA has some conceptual problems with it, too. You have to make it an object here. Look also this.
On the other hand, there should be no problems to drop a timeline to the object diagram, but in EA it IS a problem - the object-timeline remains the timeline even on the Object diagram. That is obviously non-convenient and ununderstandable, but it is so. Obviously, it is one of these bugs that are called "features".
The same is behaviour of the timeline if we drop it on the Class Diagram. We even can't connect this object to a class by generalization - EA considers such connection as a rules breaking one.
And finally, how you CAN connect the timeline/object to a class. Right-click the timeline on the sequence diagram or its copy object on the class diagram. Go to Advanced. Choose Instance Classifier - the first menu item. There you can choose an existent class or even create a new one. And the object/timeline will belong to this very class.
You can't reach this feature from the Project Browser. It is obviously, another "feature" of the EA.

In a spec-adherent UML tool, one can assign classes (among other things) to a lifeline. I think that is why you are having difficulty converting lifelines into classes: they aren't the same kind of thing! Try creating classes first and assigning them to lifelines.

To transform sequence model into class model right-click on the package choose "Transform Current Package" => Check DDL => Select Transform
I hope this helps.
Regards,
Nabil

Related

LiveBindings or OOP?

I have a question regarding OOP. I'm not new to Delphi, but I learned it by myself, mostly from the internet and didn't learned it the "correct" way. I just started to take a look at OOP some weeks ago. So this is my problem:
I have an own Class called "Session". This class is connected with Edits through Visual LiveBindings. I want to fill my class with data from a TClientDataset (there is a reason why I don't bind the dataset with the edits directly). Now I have 2 ideas:
1. I build another class which implements the Dataset and handles the opening of files and Navigation.
2. I Drag and drop the ClientDataset one my Form and connect it to my class with Livebindings, like this: DataSet <---> Class <---> Edit
I hope you understand my description. So: Which idea is better? I have the feeling that LiveBindings "destroy" the Concept of OOP. On the other hand I don't need to write Code and typecast, because the live bindings do that for me.
So which way would you choose and why? Or has somebody another idea?
I hope you understand what I mean and can help me :)
With LiveBindings it is perfectly possible to bind to objects instead of datasets.
See: http://www.malcolmgroves.com/blog/?p=1084
In summary: take look at TAdapterBindSource component. It is designed for creating LiveBindings between existing controls and custom objects. In it's onCreateAdapter event you can return a TObjectBindSourceAdapter as aBindSourceAdapter in case you want to bind one specific object, or return a TListBindSourceAdapter for binding list of objects.
LiveBindings and OOP does not bite each other!

How is a class diagram converted into code?

I was self-studying various UML diagrams and I understood most of them except for Class Diagram and Object Diagram.
I can not get my head around how they wil be converted into code.
The trick that I learnt is this: all nouns become classes and verbs become methods of the classes.
All good till there but after that, how is the diagram converted into code?
Have a look at a diagram here that I got from the internet:
So, assuming that the language is Java, how will you code a software based on this?
A UML diagram solely describes the internal architecture of a given piece of software.
The information contained in your UML diagram is therefore:
What classes are contained
What methods and properties do they contain
How do they relate to each other
Each block with a header ("Train" for instance ) represents a class, listing its properties and methods.
As such the UML diagram does not state anything about a GUI or how the user interacts with the software. It is up to you or a UI/UX designer to create an interface you can implement, that uses the functionality outlined in this UML diagram.
You can think of a UML diagram as a description of the architecture of a piece of software, that is very shallow but is well suited for an overview of the project.
It is not a recipe.
I hope this was useful to you.
When you have a class diagram, you have a representation of the classes (and its members) that you should have in code.
So, your noun/verb analysis (what you were talking about), has already been done when you have a class diagram.
A class diagram is just a visual representation of your classes, converting them to code is just easy if you know the syntax of the language that you want to use.

OOP: Is it normal to have a lot of inherited classes?

I started writing some code for a 2D game, created a class "objets" trying to keep it as generic as possible. I have a few methods and attributes that are common to every kind of element (buldings, ppl, interface buttons, etc) like (w, h, x, y ...you know) but most of them only make sense when applied to and specific type of item.
So I would have to inherit a new class for every type of actor in the game?
Just wondering if this is a common practice, or maybe i should manage it in a different way.
Thanks in advance.
If you're introducing behaviour then subclass, however if the difference is attribute based then don't e.g.
Animal (has .colour and .makeSound) -> Dog (has .eatOwnPoop) -> RedDog (no, too specific, covered by colour)
Notice how I had ".makeSound" in Animal. I could have put .bark in dog, but then I'd have to put .meow in cat etc. The subclass can simply override and provide a concrete sound.
However, you can use interfaces to better cross-cut your code, but that's quite a lengthy topic and probably overkill for your needs (although it could help any unit testing you do).
It sounds like you are over-using inheritance. It is certainly a red flag when you simultaneously say "common attributes like ..." and "...only make sense when applied to a specific type." Also, it is a red flag that domain objects such as building share a common base class with an interface object like button. Finally, it is quite unusual to define your own objet (object?) class from which every class in your system derives. It's not inconceivable, but in combination with your other comments, it sounds like you've started down an unproductive path.
You might want to refer to a good tutorial on object-oriented design and analysis such as "Head First OOA&D"
You do not HAVE to do anything. Generally, it is useful to use derived classes if they exhibit some kind of commonality but become more specialised in nature requiring specific functionality at each level of inheritance. It is also good to use if you want to have polymorphic behaviour. You have asked a very open ended question but basically do not feel that you HAVE to use inheritance as not every problem requires it and indeed some people overuse inheritance, introducing it in places where it really is not needed. All in all, I would really recommend that if you haven't already that you read a good book on object oriented design as this will then get you to think about your code from a different perspective and greatly improve the way you view software and design it. It may sound like a cop out but this kind of question is very hard to answer without knowing all details of what you are doing.

Linking classes on a Sequence diagram using Rational Software Architect

I am using Rational Software Architect to have a play at class diagrams and sequence diagrams. I created a class diagram with a number of classes. I then created a sequence diagram and tried create an operation/message between the classes.
I find that in some cases i cant create a link (message/operation) between some classes. I dont know why this is the case.
Are there some rules i should be aware of before i am able to link the classes on the sequence diagram?
Usually what happens is i click on the calling class, drag the mouse to the "Service" class to denote a method call. The problem though is that mouse shows a 'disabled' icon (similar to the no parking sign) so i cant link the two classes.
If you are using "combined fragments" in sequence diagrams it is necessary that the classes that are involved in the message (method call) are part of the same "fragment". If this is the case you can include new classes to one combined fragment by right-clicking on it and selecting "Covered Lifelines" -> "Add Covered Lifeline" on the context menu.

Create several representations of one class in UML2Tools

Good day, colleagues!
I've posted this question to Eclipse community forum of UML2Tools, but that forum is almost dead, so I post my question here:
How can I create several representations of the same class in the main window of UML2Tools?
I need this because if class has many connections with other classes(aggergations, associations, inheritance), diagram becomes very confusing.
So, in this case it's convenient to create "duplicate" of target class and make new connections on the "duplicate" class, assuming that target class has connections from both "original" and "duplicate" representation of the class.
In StarUML I can do such thing by just Copy+Paste. In UML2Tools Copy+Paste creates ANOTHER class with the same attributes. This is not what I want.
It is impossible to show different views of the same class inheritance, association and dependencies with UML2 tools.