Beginners question: How do you work with Moose?

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

Beginners question: How do you work with Moose?

Meinert Schwartau
Hi,

I'm new to Moose and Pharo and have some problems to get started. So how do you work with the moose panel?

For instance, I want to get all packages for all classes of the argouml showcase. I do this like this:

1. Select "All classes"
2. Look in the Meta-Panel which methods are available
3. Enter "self allPackages" in evaluator and execute "Do it and Go"
4. => The result shows 0

The same for allModelPackages. 

I wonder what's the difference between allPackages and allModelPackages and why both return a result of zero. I would expect to get of all the packages the classes are in.

If I do the same for the methods:

1. Select "All classes"
2. Look in the Meta-Panel which methods are available
3. Enter "self allMethods" in evaluator and execute "Do it and Go"
4. => The result shows 23k methods
5. Now I wanted to look at meta panel which methods are available but I don't see any method related except averageNumberOfInvocations and so on. The reason seems to be that the result is of type FAMIXMethodGroup. How to get from the group to the model for the methods so that I can access the parameter list of the methods and so on?

So how do you know which methods you can call, do you use the meta panel as well? Why do some methods return an empty result (like allPackages) even though they seem to be valid and should return a result? How to get to the content of a group?
Is there a more efficient way to work with moose or is this the way you work with it? How do you investigate these problems if you get some unreasonable return result?

Best regards
Meinert



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

Re: Beginners question: How do you work with Moose?

Usman Bhatti
Hi.

On Mon, Jul 11, 2016 at 12:00 AM, Meinert Schwartau <[hidden email]> wrote:
Hi,

I'm new to Moose and Pharo and have some problems to get started.

Welcome!
 
So how do you work with the moose panel?

For instance, I want to get all packages for all classes of the argouml showcase. I do this like this:

1. Select "All classes"

MoosePanel shows shows all the entities/associations found in your model. So, if packages are there you should also see "All Packages" group. If you do not see the group in the list, your parser didn't identify them (create them in the model).
 
2. Look in the Meta-Panel which methods are available
3. Enter "self allPackages" in evaluator and execute "Do it and Go"
4. => The result shows 0

The same for allModelPackages. 

I wonder what's the difference between allPackages and allModelPackages and why both return a result of zero.

When parsing a program, a parser finds some symbols and their definitions in the code. However, the definitions for all the symbols might not be available. For example, your program call a method foo but we do not have the source code of foo. In that case, this method becomes a stub. All queries of type allModelEntityName return a list of non-stub entities. allPackages should return all the packages (stub/non-stub identified in the program). If they both return 0, I suspect there are no packages in the model.
 
I would expect to get of all the packages the classes are in.

Try doing something like this on model: self allModelClasses collect: #parentPackage. If the list is empty, the parser didn't create packages in the model since allModelPackages returns empty collection.
 

If I do the same for the methods:

1. Select "All classes"
2. Look in the Meta-Panel which methods are available
3. Enter "self allMethods" in evaluator and execute "Do it and Go"
4. => The result shows 23k methods
5. Now I wanted to look at meta panel which methods are available but I don't see any method related except averageNumberOfInvocations and so on. The reason seems to be that the result is of type FAMIXMethodGroup. How to get from the group to the model for the methods so that I can access the parameter list of the methods and so on?

FAMIXMethodGroup inherits from MooseAbstractGroup that contains an entity collection and provide methods to iterate over individual elements. I would send this message to the group to collect all parameters: self collect: #parameters 
 

So how do you know which methods you can call, do you use the meta panel as well?

Yes, + class hierarchy.
 
Why do some methods return an empty result (like allPackages) even though they seem to be valid and should return a result?

If there are no packages in the model, the result is valid.
 
How to get to the content of a group?

self entityStorage. But you rarely want to do it. Instead you iterate over the entities.
 
Is there a more efficient way to work with moose or is this the way you work with it? How do you investigate these problems if you get some unreasonable return result?

Mostly in MoosePanel + debugger to see entities and the connections of individual elements.

HTH.
Usman
 

Best regards
Meinert



_______________________________________________
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: Beginners question: How do you work with Moose?

abergel
In reply to this post by Meinert Schwartau
Hi Meiner!

> For instance, I want to get all packages for all classes of the argouml showcase. I do this like this:
>
> 1. Select "All classes"
> 2. Look in the Meta-Panel which methods are available
> 3. Enter "self allPackages" in evaluator and execute "Do it and Go"
> 4. => The result shows 0

In Moose, for Java application, a package is called a namespace. So, look for namespaces and not packages.

> The same for allModelPackages.
>
> I wonder what's the difference between allPackages and allModelPackages and why both return a result of zero. I would expect to get of all the packages the classes are in.

allPackages are all the packages _defined_ and _used-but-not-defined_ of your application.
Same for classes and model classes.

If your application is:

public class MyGreatApp extends Object {
        public static void main(String[] args) {
                System.out.println(“Hello World”);
        }
}

then all model classes will give you the class MyGreatApp. However, allClasses will give you, at least, Object, String, System since your application use these classes, but they are not defined in your application.

> If I do the same for the methods:
>
> 1. Select "All classes"
> 2. Look in the Meta-Panel which methods are available
> 3. Enter "self allMethods" in evaluator and execute "Do it and Go"
> 4. => The result shows 23k methods

Okay!

> 5. Now I wanted to look at meta panel which methods are available but I don't see any method related except averageNumberOfInvocations and so on. The reason seems to be that the result is of type FAMIXMethodGroup. How to get from the group to the model for the methods so that I can access the parameter list of the methods and so on?

Can you take a screenshot? I am not sure what are you looking at.

> So how do you know which methods you can call, do you use the meta panel as well? Why do some methods return an empty result (like allPackages) even though they seem to be valid and should return a result? How to get to the content of a group?
> Is there a more efficient way to work with moose or is this the way you work with it? How do you investigate these problems if you get some unreasonable return result?

I am also online, on Slack, if you wish to have a chat.

Cheers,
Alexandre

--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.



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

Re: Beginners question: How do you work with Moose?

Meinert Schwartau
Ok thanks for the two answers. They helped me a lot. I just started to read the current snapshot version of the pharo by example book which clarified some open points too. So I think I can proceed now.

Best regards
Meinert

> Am 11.07.2016 um 14:17 schrieb Alexandre Bergel <[hidden email]>:
>
> Hi Meiner!
>
>> For instance, I want to get all packages for all classes of the argouml showcase. I do this like this:
>>
>> 1. Select "All classes"
>> 2. Look in the Meta-Panel which methods are available
>> 3. Enter "self allPackages" in evaluator and execute "Do it and Go"
>> 4. => The result shows 0
>
> In Moose, for Java application, a package is called a namespace. So, look for namespaces and not packages.
>
>> The same for allModelPackages.
>>
>> I wonder what's the difference between allPackages and allModelPackages and why both return a result of zero. I would expect to get of all the packages the classes are in.
>
> allPackages are all the packages _defined_ and _used-but-not-defined_ of your application.
> Same for classes and model classes.
>
> If your application is:
>
> public class MyGreatApp extends Object {
>    public static void main(String[] args) {
>        System.out.println(“Hello World”);
>    }
> }
>
> then all model classes will give you the class MyGreatApp. However, allClasses will give you, at least, Object, String, System since your application use these classes, but they are not defined in your application.
>
>> If I do the same for the methods:
>>
>> 1. Select "All classes"
>> 2. Look in the Meta-Panel which methods are available
>> 3. Enter "self allMethods" in evaluator and execute "Do it and Go"
>> 4. => The result shows 23k methods
>
> Okay!
>
>> 5. Now I wanted to look at meta panel which methods are available but I don't see any method related except averageNumberOfInvocations and so on. The reason seems to be that the result is of type FAMIXMethodGroup. How to get from the group to the model for the methods so that I can access the parameter list of the methods and so on?
>
> Can you take a screenshot? I am not sure what are you looking at.
>
>> So how do you know which methods you can call, do you use the meta panel as well? Why do some methods return an empty result (like allPackages) even though they seem to be valid and should return a result? How to get to the content of a group?
>> Is there a more efficient way to work with moose or is this the way you work with it? How do you investigate these problems if you get some unreasonable return result?
>
> I am also online, on Slack, if you wish to have a chat.
>
> Cheers,
> Alexandre
>
> --
> _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
> Alexandre Bergel  http://www.bergel.eu
> ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
>
>
>
>
_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev