Class in the attribute compartment of another class - object

Is it possible to add a class as an attribute of another class?
If it is normal situation, how can I do this?

There are two (possibly three) ways of doing this:
1- using the attribute text.
2- using the association notation.
(3- both)
See this image.
This is the full article by Craig Larman.

This is absolutely normal.
Response by #jurgenreza is comprehensive.
Among the various options he shows, I'm one of the detractors of option 3 (because of redundancy).

Related

Sparx Enterprise Architect: Show programming language in component diagram

I am using Sparx Enterprise Architect and am somehow confused that I did not find any hint on the internet regarding the following question: How can I show the programming language of a component in the component diagram?
It is clear to me that I could use custom stereotypes but this is not a good idea as it prevents me from using "real" stereotypes later on.
The reason is simply that you can not show it using EA's GUI. You would need to stereotype the element and come up with a shape script to display the language with a
print("#language#");
somewhere.
To assign a shape script to a stereotype there are two ways, the quick and dirty and the difficult one. Here's the q&d one:
Under Configure/UML Types you can add a new 'wild' stereotype. That is one with no profile. EA will show that as <none> when applied. Think of a fitting name and choose Edit with the shape script:
Here can enter the new shape script (since this depends very much here's a simple one):
shape main {
Rectangle(0, 0, 100, 100);
println("#name#");
println("#language#");
}
Save the edit and close the dialog. Once you assign the stereotype to an element it will render like this:
I know this is not pretty and you need to dig into shape scripts to make it useful, but that can't be avoided.
So the difficult, but better and preferred, way is to create your own profile containing the stereotype along with the shape script. The above would just be a way of testing it but finally you would need to create your profile and put it in a MDG. Since this is a quite complex task it won't go here into this answer (no, I'm not Fermat, but you need quite some effort to get that far).
There is no standardized way to show the programming language of a component in UML. There are several ways you can do it, for example:
Stereotype. This will not prevent you from adding other stereotypes in the future. Multiple stereotypes are shown comma separated: «stereotype1, stereotype2»
Generalization. You can define a component called 'JavaComponent' and let all Java components inherit from this base component.
Note. You can attach a note to the component specifying the language.

How to indicate in class diagram that an object will have versions?

I have a Text class. Objects of this class will have many versions. So there will be history of text changes.
How to indicate this on class diagram properly?
I need to show when it was changed and by who? Create class for text change? It is littlebit strange. Generalization?
Thanks for answer.
How's this diagram below? (I'm sorry if I am misunderstanding your description.)
Also, the Memento design pattern may help you.

Visual Paradigm Class Diagram Drawing

I need to create a Class Diagram with some Model Packages. I have to use Visual Paradigm as modeling editor. The target I'm looking for is a diagram like this one:
My problem is the following: how to create a Class like the classes in this picture?
I'm trying with the default Class command:
but it's not what I'm looking for. The class name must be centered and without the separation line. How can I do this?
I have also tried with Rectangles and Text Boxes overlapped, but in this case I'm not able to draw associations between the classes.
Thanks in advance.
The solution is very simple: you have to hide all the class attributes and methods (thank you, clapas!)

Tool to refactor .xsd schema?

I got an .xsd scheme that has multiple root elements, few complex and simple types, complex types refer to those root elements. I can't generate .xml in a way i want from it because of those root elements. So i think i need to add element that will serve as the root element, and add all other elements as its children, or am i wrong?
Is there a tool that can help me create root element and refactor scheme? What i got:
I was thinking maybe i just need to create another xsd with 1 element and ref all elements form first xsd in it, but i don't exactly know how to do it. Is this a good idea?
The answer to your edit is indeed, as Pangea said, NO. And that is because to ref another element (as in <xsd:element ref="SomeElement" ... />), the referenced element must be declared globally.
Other scenario that requires global elements is the use of substitution groups. What I am trying to suggest is that it may not always be possible to refactor an XSD in a way that leaves global only the elements you want as root in instance XML.
Which should make you think that to solve your problem, a better way might be to go after the reason why you can't generate .xml the way you want. If you can describe a bit of that, you might get a better answer here...
Another reason I wanted to add this answer was that I noticed the use of XML as a tag name. While it may seem OK, I can tell you that I've seen some pretty "big-name" applications that would simply choke with that <XML/> tag name. XML is actually "reserved", please take a look at this section of the XML Spec. To quote: "Names beginning with the string "xml", or with any string which would match (('X'|'x') ('M'|'m') ('L'|'l')), are reserved for standardization in this or future versions of this specification."
Always play nice with the specs....
Any global element you define in the schema is a potential root element in the the instance document. If you doesn't want this behavior then make sure you have only one global element definition in the xsd. It has nothing to do with the tool (though xml editors can simplify this).

Seam component reuse - outjected #DataModel variable conflict

I need your suggestions as usual ;)
In my Seam app, there's a JSF view page processing 3 similar types of data, so I wrote a Seam component and would like to reuse it three times. The problem is, the component outjects some data used by the view into #DataModel variable. Now, is there a clever way to variate three conflicting variable names without using inheritance etc? If not, what kind of other approach would you suggest? Thanks in advance.
i suggest don't use outjection and use inheritance and just getters to access variable.
ie: #{bean1.var} #{bean2.var} #{bean3.var}

Resources