I've been wondering how to model interface between two components using it's rectangular representation (not lollipop) with all the details (attributes, operations).
I have two components and interface that lets them to "talk" to each other.
Using "lollipop" notation I would do this in this way:
But I didn't know how to attach my interface definition to this flow.
Is it correct to attach it to the line of Information Flow? What type of assotiation use to do this?
I found in OMG specifiaction the following description.
The component providing the interface REALIZE it. The one that consume it - USES it.
Recreating the diagram gave me this state:
Related
My component diagram is mostly components, ports, and interfaces. The interfaces have operations and attributes. They do not capture any class based OO at the moment. What's the right way of doing that?
My options as I see them is either:
Add the class constructors to the component interfaces, and let the type carry remaining details like class operations.
Duplicate class interfaces into the component interfaces, e.g. having the class object as first parameter.
From the two the former is least work obviously. But perhaps there is a better way I've overlooked.
Notation
The easiest way to do this is to capture the interfaces in a separate class diagram, with only «interface» classifiers. The advantage is that these classifiers give a (hopefully short) name to an interface, and describe the attributes and operations that are needed, with all required details, including constructors (keep in mind that in UML constructors should be preceded with «Create»)
You can then show for the components in your component diagram the interfaces provided (lollipop) and required (socket) just referring to the named interfaces, without cluttering the diagram with lots of redundant interface specifications.
Design
When you refer to duplicating class interfaces at the component level, I understand that you mean to add attributes (parts?) and operations to the component.
Of course, components implementing the same implicit interface could in principle be interchangeable. However, this approach does not allow to have a clear understanding of the dependencies, and in particular use dependencies, that are practical to decouple components. In other words, your components would be hard-wired.
Adding class constructors at the component level seems cleaner in this regard, since your class constructor would reuse classes that are defined somewhere else. But if you're going into that direction, you could go one step further and consider using a factory class:
The factory class constructs objects of a given class or a given interface
Your component would be initialized or configured with such factory provided from outside. The factories could be interchanged to construct different kind of objects that meet the requirements.
*. If you go that way, I come back to the notational topic: the lolipo/socket notation would then allow to highlight better the decoupling that this design would offer.
I didn't understand the options you describe. Maybe a diagram would help. Here is how I would do it:
The specification component has two ports and is indirectly instantiated. For the realization component I select two classes that are realizing the component. Class1 has an operation that uses the service defined by interface I1. Class2 implements the service promised by I2. Since port p2 has a multiplicity of 16, the part typed by Class2 also has at least this multiplicity. The constructors (with the «create» stereotype), don't have parameters, so that the component can be constructed without any additional logic.
If you need additional logic, you can use directly instantiated components. They have constructors that could call the parametrized constructors of realizing classes and also create the wiring.
I do not understand the meaning of class in Modelica context.
From the Modelica Tutorial, version 1.4 on https://modelica.org/publications.html:
In Modelica, the basic structuring element is a class. There are seven restricted classes with specific names, such as model...". Anyone have a simpler explanation? I am very new to Modelica.
If you open the Modelica library in a tool like Dymola or OpenModelica, everything you see in the package or library browser are classes.
As soon as you use one of these classes, e.g. with drag and drop in the diagram layer, you create a new component of this class type.
The instantiated component is not a copy of the class, but a reference to it. Therefore, if you update the class definition, you also update the behavior of all components that are instances of this class.
There are several kinds of classes available. The most general class is actually called class, but it’s not used very often.
It has no restrictions, so it can contain everything that is possible with Modelica: equations, algorithms, public and protected components, etc.
There are more specific class types, which restrict the usage. This helps to make correct use of a class. A function or a record for example cannot be simulated.
The most important restricted class types are:
package: used to group other classes
model: typically used for components with physical connectors and for examples which are simulated
block: used for components with causal connectors (only inputs and outputs, so everything you have in Modelica.Blocks)
function: used for function calls, comparable to other programming languages
record: often used to contain data sets for other components (which allows to quickly change a complete data set)
connector: used to define the interface variables which are needed to connect different components of a domain (e.g. v and i in the electric domain)
type: typically used to define physical quantities like mass, length or time with their unit (e.g. all units in the package Modelica.Units)
More information can be found in chapter 4.6 of the Modelica specification: Specialized Classes
This is just a collection of links to prove that there is an ongoing discussion on class within the Modelica Association:
class still a valid Modelica class type to use?
model no longer identical to class
What is the usage recommendation for class?
Restricted class for parameter record with initial equation
As the title suggest what is the difference between the three and when should one use one of the three instead of the other two?
The internet is filled with their definition but i couldn't find any text or explanation on when and where to use required interface or the <<use>> dependency.
There are only two cases in fact: realize/use on the one hand, and provided/required on the other. They essentially describe the same thing, but with different emphasis.
With realize/use you draw visible relationships from the class (or component, as in my examples below) to the interface, and thus show the interface and its operations in the diagram.
You could, of course, split that into two different diagrams.
With provided/required, on the other hand, the interface is only shown as lollipops so you can't see the operations. But you can draw visible relationships (usually "assembly") between the lollipops.
I'd say that realize/use is more appropriate if you want to show who implements what. Provided/required is more appropriate if you want to focus more on interactions between parts.
A required interface is usually shown as socket. It means that in order to have the class working it needs at runtime a counterpart with a lollipop. This counterpart in turn offers the interface via a lollipop. To decouple class and interface definition you put the interface in a stereotyped class and draw a realization from the providing class to the interface. Vice versa you draw a dependency from the requiring class to the interface. Whether you stereotype the dependency with <<use>> is more a matter of taste.
as described above and as alternate representation:
I'm making a class diagram for a project.
How can I describe vectors, lists, files or unsigned types?
I would like to make a detailed diagram so I need to specify the types of the members and the input/output parameters of the methods.
Thank you all!
For more detailed description of the inner structure of the class you need a Composite Structure Diagram. There you can describe your methods as "ports". And your fields as attributes. You can show there really almost everything!
For detailed description of the specific instances of the class and their mutual behaviour you need an Object diagram.
At the links applied you can see a bit how to make them. But take it as a start only.
The class diagram is too common to describe the inner structure of the class. It is tooled for the description of the inter-classes relations. So, you can put your information into the model of the class, but some of it won't be seen on the diagram. But I would advise you to start from the class diagram and make it as detailed as it can show and only later go to more detailed diagrams. Maybe you won't need them after all.
Edit:
You can make a port on the border of your class, name it fileName and connect it to io interface you use. (Composite Structure Diagram only)
As for vector/list, it is easier, and could be done in a Class Diagram. If you want to show that some attribute is a vector or list, simply write: someAttr:List or put a List block on the diagram, draw association to it and name its end "someAttribute". You could do it with File, too, but there you should draw more, I think, to show the used io interface.
For showing attributes in class diagram also look here.
You should use an uml class diagramm. [Link][1]
In a class diagramm you can relate class members with types, functions with parameters and signatures.
[1] http://www.holub.com/goodies/uml/
(Somebody can format this? IMHO SO app can not handle links..)
Your question is not clear to me. There are two variants:
you need to define what type of collections (vector, list etc) in specific programming language should be used to implement multicity element ([N], [0..N] ordered or unordered, unique or nonuniqu)
It is not possible to explicitly define in UML. You can only declare, what type it is. For example in note or constraint
You need simply define types of collection
Use ordinary class or DataType element to define
Standard syntax for member (attribute, port etc.) is following: +name:Type[Multiplicity]{contraints}
The same syntax is used for parameters (all types) of operation (methods in programming language)
I would like to change the way Wicket instantiates my Page instance for a subset of URLs. Normally, I would map a class to a URL with mount(), in which case Wicket chooses one of the available constructors on that class and instantiates it.
A part of my application are simple CRUD operations that have a lot in common between different entity types. I have factored out the common aspects into some factory and helper classes and now I'm left with a class hierarchy for my pages which looks like this:
TemplatePage
|
AbstractEntityPage
| |
AbstractVenuePage AbstractEventPage
| | | |
ViewVenuePage EditVenuePage ViewEventPage EditEventPage
I would like to cut the last two levels, because the hierarchy starts to sprawl as more entity types are added and there's very little code left in those classes which could be factored out easily to more generic objects.
It's rather easy to transform AbstractEntityPage into a class EntityPage that gets specific components plugged in place as needed. I would normally use a Builder to do this, but I'm not sure how I would tell Wicket to use it? I couldn't find a hook for that in the API docs.
You can replace the default IPageFactory with org.apache.wicket.settings.ISessionSettings.setPageFactory(IPageFactory) and use different strategy of instantiating the page if it is special one.
You could use an EntityPage and implement the differences within your panels, but then you'd need a lot of similar panels (or a few generic panels if they don't really differ). Or you could take a look at one of the rapid prototyping libraries for wicket like wicketopia. I wouldn't consider any of them (the ones I found and tested) to be production-ready but they can be salvaged for ideas g.