Finding UML <<create>> association in Moose?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Finding UML <<create>> association in Moose?

Fuhrmanator
Hi all -- I'm not sure if I missed it, but does Moose explicitly model the <<creates>> relationship of UML between two classes, e.g.,
Based on http://themoosebook.org/book/index.html#h1thefamixfamilyofmeta-models I found Entity -> SourcedEntity -> Association -> {Access, Invocation, Inheritance, Reference}. In Moose, I can see outgoingInvocations on methods of a class contain "new X" for all the X that a class creates, but I wondered if there's a more efficient way. 

Cheers!

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Finding UML <<create>> association in Moose?

Nicolas Anquetil

Hi,

no there is nothing special for <<create>>.

"Creation" actually seems something different than the associations you list: Access, Invocation, Inheritance and Reference can be lexically extracted from the source code and they are fundamental mechanisms of many programming languages.

But it should not be too difficult to model it in Famix and post-process a model to discover all occurences

cheers

nicolas


On 29/03/2018 23:25, Cris Fuhrman wrote:
Hi all -- I'm not sure if I missed it, but does Moose explicitly model the <<creates>> relationship of UML between two classes, e.g.,
Based on http://themoosebook.org/book/index.html#h1thefamixfamilyofmeta-models I found Entity -> SourcedEntity -> Association -> {Access, Invocation, Inheritance, Reference}. In Moose, I can see outgoingInvocations on methods of a class contain "new X" for all the X that a class creates, but I wondered if there's a more efficient way. 

Cheers!


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev

-- 
Nicolas Anquetil
RMod team -- Inria Lille

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Finding UML <<create>> association in Moose?

Fuhrmanator
Hi Nicolas,

Thanks - indeed, iterating over Moose class methods with 

... methods select: [:m | m kind = 'constructor']

finds all the constructors pretty easily (parentType to find createe). Then it's the incomingInvocations' sender parentType to find the creators. 

Cheers!

On Fri, Mar 30, 2018 at 3:15 AM, Nicolas Anquetil <[hidden email]> wrote:

Hi,

no there is nothing special for <<create>>.

"Creation" actually seems something different than the associations you list: Access, Invocation, Inheritance and Reference can be lexically extracted from the source code and they are fundamental mechanisms of many programming languages.

But it should not be too difficult to model it in Famix and post-process a model to discover all occurences

cheers

nicolas


On 29/03/2018 23:25, Cris Fuhrman wrote:
Hi all -- I'm not sure if I missed it, but does Moose explicitly model the <<creates>> relationship of UML between two classes, e.g.,
Based on http://themoosebook.org/book/index.html#h1thefamixfamilyofmeta-models I found Entity -> SourcedEntity -> Association -> {Access, Invocation, Inheritance, Reference}. In Moose, I can see outgoingInvocations on methods of a class contain "new X" for all the X that a class creates, but I wondered if there's a more efficient way. 

Cheers!


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev

-- 
Nicolas Anquetil
RMod team -- Inria Lille

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev



_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Finding UML <<create>> association in Moose?

Tudor Girba-2
+1

Doru


> On Apr 1, 2018, at 5:58 AM, Cris Fuhrman <[hidden email]> wrote:
>
> Hi Nicolas,
>
> Thanks - indeed, iterating over Moose class methods with
>
> ... methods select: [:m | m kind = 'constructor']
>
> finds all the constructors pretty easily (parentType to find createe). Then it's the incomingInvocations' sender parentType to find the creators.
>
> Cheers!
>
> On Fri, Mar 30, 2018 at 3:15 AM, Nicolas Anquetil <[hidden email]> wrote:
> Hi,
>
> no there is nothing special for <<create>>.
>
> "Creation" actually seems something different than the associations you list: Access, Invocation, Inheritance and Reference can be lexically extracted from the source code and they are fundamental mechanisms of many programming languages.
>
> But it should not be too difficult to model it in Famix and post-process a model to discover all occurences
>
> cheers
> nicolas
>
> On 29/03/2018 23:25, Cris Fuhrman wrote:
>> Hi all -- I'm not sure if I missed it, but does Moose explicitly model the <<creates>> relationship of UML between two classes, e.g.,
>> <image.png>
>> Based on http://themoosebook.org/book/index.html#h1thefamixfamilyofmeta-models I found Entity -> SourcedEntity -> Association -> {Access, Invocation, Inheritance, Reference}. In Moose, I can see outgoingInvocations on methods of a class contain "new X" for all the X that a class creates, but I wondered if there's a more efficient way.
>>
>> Cheers!
>>
>>
>> ______________________________
>> _________________
>> Moose-dev mailing list
>>
>> [hidden email]
>> https://www.list.inf.unibe.ch/listinfo/moose-dev
>
> --
> Nicolas Anquetil
> RMod team -- Inria Lille
>
>
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.list.inf.unibe.ch/listinfo/moose-dev
>
>
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.list.inf.unibe.ch/listinfo/moose-dev

--
www.tudorgirba.com
www.feenk.com

“Programming is executable philosophy."

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Finding UML <<create>> association in Moose?

Fuhrmanator
Here's a script that I ran on an MSE generated from Java code at https://github.com/bethrobson/Head-First-Design-Patterns to show the <<creates>> relationships in the AbstractFactory example.

I had some trouble with RTMondrian and custom composite shapes. I wasn't able to set the colors of the individual elements in the RTCompositeShape that I passed for the nodes. I tried working around it with @RTLabeled, but it prints an "X" where the Character cr is in the string (rather than wrapping). Finally it kind of works with border/fill/textColor: on the RTMondrian shape, but it's not what I expected. 

============================

"blocks for readability"

findCreators := [ :class | | findConstructors creators | 
    findConstructors := [ 
            :cclass | cclass methods select: [ :m | m kind = 'constructor'] ].
    creators := Set new. 
    (findConstructors value: class) do: [
:method | method incomingInvocations do: [ 
:ii | creators add: ii sender parentType ]
]. 
creators. ].

newLine := Character cr asString.

camelWrap := [ :class |
rex := '([a-z])([A-Z])' asRegex.
rex copy: class name translatingMatchesUsing: 
    [ :each | (each at:1) asString, newLine, (each at:2) asString ]
  ].

classes := MooseModel root allModels first allClasses select: [
:c | c mooseName beginsWith: 'headfirst::designpatterns::factory::pizzaaf'].

thinArrow := RTDecoratedLine new
head: (RTFilledNarrowArrow asHead);
attachPoint: (RTBorderAttachPoint new);
width: 2.

"inheritanceArrow := RTDecoratedLine new
head: (RTEmptyNarrowArrow asHead);
attachPoint: (RTBorderAttachPoint new);
width: 2."

myClassShape := RTCompositeShape new
    add: (RTBox new); 
    add: (RTLabel new text:camelWrap);
    allOfSameSizeWithPadding.

b := RTMondrian new.
b shape shape: myClassShape; 
    borderColor: Color black;
    fillColor: Color paleYellow;
    textColor: Color black.
b nodes: classes.
b shape shape: thinArrow; 
    color: Color veryLightGray.
b edges moveBehind; connectFromAll: findCreators.
"b shape shape: inheritanceArrow; 
    color: Color green; withShorterDistanceAttachPoint.
b edges connectToAll: #directSuperclasses."
b layout dominanceTree verticalGap: 80; horizontalGap: 5.
b build.
b view @ RTZoomableView.
^ b

=======================================


Adding inheritance to the tree is commented out, but it makes for a mess when laying out both creation and dependency.

I had wanted to use RTUMLClassBuilder to show the <<creates>> relations, but finally I gave up since it appears to have inheritance only hard-coded in the edges. I remember someone saying it should/would be re-done with RTEdgeBuilder, so I'm looking forward to that.

Another suggestion for RTUMLClassBuilder would be a message forMooseClasses (at least with Java in Moose, maybe forMooseJavaClasses?) message that has these values:

forMooseClasses
self  classname: #name.
self  instanceVariables: #attributes.
self  methodsNames: #methods.
self  superclass: #superclass.
self  methodselector: #signature. self  attributeselector: #name

It yields something like this which is nice:

Hope this feedback is useful. 

Cheers,

C. Fuhrman

On Sun, Apr 1, 2018 at 1:18 AM, Tudor Girba <[hidden email]> wrote:
+1

Doru


> On Apr 1, 2018, at 5:58 AM, Cris Fuhrman <[hidden email]> wrote:
>
> Hi Nicolas,
>
> Thanks - indeed, iterating over Moose class methods with
>
> ... methods select: [:m | m kind = 'constructor']
>
> finds all the constructors pretty easily (parentType to find createe). Then it's the incomingInvocations' sender parentType to find the creators.
>
> Cheers!
>
> On Fri, Mar 30, 2018 at 3:15 AM, Nicolas Anquetil <[hidden email]> wrote:
> Hi,
>
> no there is nothing special for <<create>>.
>
> "Creation" actually seems something different than the associations you list: Access, Invocation, Inheritance and Reference can be lexically extracted from the source code and they are fundamental mechanisms of many programming languages.
>
> But it should not be too difficult to model it in Famix and post-process a model to discover all occurences
>
> cheers
> nicolas
>
> On 29/03/2018 23:25, Cris Fuhrman wrote:
>> Hi all -- I'm not sure if I missed it, but does Moose explicitly model the <<creates>> relationship of UML between two classes, e.g.,
>> <image.png>
>> Based on http://themoosebook.org/book/index.html#h1thefamixfamilyofmeta-models I found Entity -> SourcedEntity -> Association -> {Access, Invocation, Inheritance, Reference}. In Moose, I can see outgoingInvocations on methods of a class contain "new X" for all the X that a class creates, but I wondered if there's a more efficient way.
>>
>> Cheers!
>>
>>
>> ______________________________
>> _________________
>> Moose-dev mailing list
>>
>> [hidden email]
>> https://www.list.inf.unibe.ch/listinfo/moose-dev
>
> --
> Nicolas Anquetil
> RMod team -- Inria Lille
>
>
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.list.inf.unibe.ch/listinfo/moose-dev
>
>
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.list.inf.unibe.ch/listinfo/moose-dev

--
www.tudorgirba.com
www.feenk.com

“Programming is executable philosophy."

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev