UCOSPLogBlakelyQuebecDesloges

Kevin Brightwell edited this page Aug 26, 2015 · 1 revision
Clone this wiki locally

Each UCOSP participant is asked to log all their accomplishments as well as the difficulties they have getting set up to understand Umple and other experiences they have. Difficulties might include understanding how to model in Umple, using UmpleOnline, code that is difficult to figure out, and development tools that are hard to figure out, or don't seem to work properly. The more log entries added the more we can better get a grip on the usability issues with Umple, and the more we can help future new contributors come up to speed.

Log entries in reverse chronological order

April 7

During my mission to get the .jet files that I’ve created and modified to compile so that I could actually test my solution to issue 351 (on Google Code) I’ve been running into all sorts of problems in Eclipse when trying to build the jet templates. I’ve made sure that the projects UmpleToJava, UmpleToPhp, and UmpleToRuby are configured so that the Templates Container and the Source Container are set to “templates” and “src” respectively, but whenever I try to build the projects using the JET builder from within Eclipse I keep getting errors that say the project is out of sync with the file system.

One of the problems that I thought may be occurring was that the contents of the cruise.umple.compiler.java folder were not being copied over the old contents in the same package name of cruise.umple, which happens if Eclipse is not set up to do it automatically. I tried fixing this issue by including the project cruise.umple in each of the jet projects’ build path but it was to no avail.

In order to cover all of the test cases for this issue I’ve created a separate test case for each of the different cases in UmpleToTemplate/templates/association_Set_All.jet where an association variable is checked to see if it has an OptionalOne multiplicity. In total there are 6 distinct instances that need to be covered, for example when an association variable has one end with a multiplicity of 1 and the other end with the multiplicity 0..1 the expression “av.isOptionalOne() && relatedAssociation.isOne()” would evaluate to true. In case I cannot solve the eclipse problems I mentioned above soon I will post these test cases to the issue page so that they will be accessible. I will also attach the .jet files I have created and modified to the issue page.

April 1

I have just created the new .jet file which will generate the add(), addAt(), and remove() methods in java and have made modifications to the file association_Set_All.jet so that it will now include the file “association_AddOptionalOne.jet” whenever an association with an optional multiplicity is found.

After taking some time to understand the structure of a .jet file and what certain syntax means (thanks Geoff) I was able to create the new .jet file of my own. I spent some time on the wiki trying to find more general information on .jet files so that I would feel more confident about modifying/creating them but I couldn’t find that much. So the next best thing is to look directly at the source code and see what kind of methods are being called and follow them back to the original class they were defined in to see how they work. Once I was able to understand how things were handled inside of types of brackets like “<% %>”, “<%= %>”, and “<%@ includefile = "somefile" %>” everything made a lot more sense.

Now I just need to find out if my .jet files generate the desired code but I’ll have to first edit the “association_Set_All.jet” file within Eclipse (which I haven’t been using for the past 2 months due it causing so many problems). Hopefully I will just need to edit this one file in eclipse and be able to then create the other .jet files with a separate editor and place them in their proper directories.

March 25

After looking at the .jet files in UmpleToTemplate and UmpleToJava I have a good idea about how to go about fixing this issue. In the UmpleToTemplate directory is a .jet file called “association_Set_All.jet” that analyses an association and determines which mutator methods (ex. set(), add(), remove() ) should have code generated.

Within this file I have found the methods that check an association to see if it has an optional multiplicity and I can observe that right now only set() methods are being flagged as methods to be generated and nothing else. Clearly I am going to have to modify the methods so that they also indicate that add() and remove() should be generated.

Within the UmpleToJava (and other Language directories) .jet files will need to be added that will generate the add() and remove() methods. From what I’ve noticed from other .jet files in this directory it seems like a separate .jet file will need to be created for each corresponding type of association multiplicity (i.e. Optional to Many, Optional to One, Optional to Optional, etc..) but I am unsure on this matter. It would be nice if only one .jet file was needed to be created that could generate the add() and remove() methods for all associations with multiplicities of 0..1 but I am doubtful that this is possible. Php and Ruby are the other languages that also need to have .jet files created in their directories. This may be difficult as I’ve never programmed in these languages before.

Another thing that needs to be looked at is how the testing for this issue will be done. It seems that my test cases (which will contain associations of the form detailed in my last log post) can be compiled and then the resultant output can be compared with the expected output. It looks like I am going to need to use some assert tests from the TemplateTest.java file to do this. Also, before and after code injections need to be checked to see if they work for the new methods.

March 20

I’ve recently begun looking into issue 351 (on Google Code). It is an issue that seems like a pretty important one because it has to do with code for methods not being generated when in fact it should be. More specifically the issue is that umple is not generating code for the add() and remove() methods for an entity in an association when the association is created with a multiplicity of 0..1 (meaning optional).

So far I’ve noticed this issue appearing in all of the cases below: class X { 1. x1 -- 0..1 W w1;

0..1 x2 -- 0..1 W w2; 1. . * x3 -- 0..1 W w3; * x4 -- 0..1 W w4; }

class W {}

The add and remove methods for associations w1-w4 should be generated in class X but they are not. Generation of these methods is logical because if the association is specified as having 0 or 1 entities of class W in the association then either one of two options is possible:

1) 0 entities are currently in the end of the association so it should be possible to add one.

2) 1 entity is currently in the end of the association so it should be possible to remove one.

Currently the only methods generated for the interface of an association-end with an optional multiplicity are the get() and set() methods.

I am about to start digging around the code generation files to see where a fix can be implemented.

March 14

First of all I checked if issue 339 (on Google Code) applied to interfaces and found out it did not.

To complete the fix for this issue I had to modify 2 different methods in UmpleInteralParser_CodeClass.ump: analyzeExternal(...) and analyzeClass(...).

The analyzeExternal(..) method is called whenever a token that represents an external definition is found when parsing a class. It then calls the analyzeClass(..) method on the token and then immediately after that it sets the modifier of the class to “external”. The problem was even if the same class was declared somewhere else in the file the “external” modifier was not being removed. So when the code generation takes place for this file each class is checked to see if it has the external modifier set and if it does no code generation for the class occurs.

The way I fixed this was by covering 2 cases. Pretend the class we are dealing with is called “X”. Now an external definition of X can either occur before or after a class specification for X. In the analyzeExternal() method I check in the umple model if there is already a class named X, and only if there is no class found the modifier of X is set to external. This is the first half of the solution that covers when an external definition is found after a class specification of X.

If X’s modifier is set to external because an external definition of X was parsed first, this problem has to be addressed in the analyzeClass(..) method. A simple check is added into this method to check whether the token being analyzed is in fact a class definition and then removing the external modifier if it is set.

March 7

After taking into consideration what Tim told me in the hangout this week I have found a different and more logical place to make the modification to fix issue 339 (on Google Code). My first solution was going to be making a modification in the code generation files because that was the only place I could find that dealt with 'external' definitions. But the problem in making modifications in code generation files is that you would have to modify each different languages' generator code.. which is time consuming and more complex than the solution should be.

From looking over some parser classes again I found a method in UmpleInternalParser_CodeClass.ump called analyzeExternal(Token externalToken) which analyzes a class if it has the 'external' definition preceding it and then proceeds to set the modifier to external. This is important to note because when I was looking at the code generation classes I noticed that before code is generated for a class a check is performed to see if the class has a modifier set to 'external'. This made me happy! Now I know that this is where I can make my modification make sure a class's modifier is not set to external if there are other specifications of the class in a file.

I also noticed that there is a similar method called analyzeExternalInterface(Token externalToken) which deals with external definitions of interfaces which I think might have the same problem as with classes. If i can fix this issue for classes I can probably just use the same solution and apply it to interfaces as well but I will first test to see if the same issue exists with interfaces.

Still thinking about how I'm going to best implement a fix inside this file (which will most likely be in the analyzeClass() method) because I want to make the fix as simple as possible.

March 5, 2013

Currently I am working on issue 339 (on Google Code) which has to do with external definitions in a file causing no code to be generated for classes declared in the file with the same name. What Umple should do is ignore the external definition if it finds a class with the same name somewhere else in the file.

So far I’ve done a lot of reading through the main source code files of umple such as Parser.ump, UmpleInternalParser.ump, Umple.ump, etc... to try to find where the modification should go. It took me a while to finally find the right place to make the change and that place happens to be in the file Generator_CodeJava.ump. This file is the only place I could find anything to do with “external” declarations and it is going to have to be where I make some changes.

In Generator_CodeJava.ump is a method called generate() which iterates through all of the UmpleElements in a file and generates the code for each class/interface/etc... My first attempt was to modify the .getUmpleElements() method in the UmpleModel so that the declarations "external X {}" and "class X { ... }" would be returned as 2 different UmpleElements. That way Umple would not generate any code when an UmpleElement has the "external" modifier and if later on in the file a class declaration with the same name as an external declaration is found then Umple will still generate code for the class. This did not work as there was no way I could modify the code in that method to do this so I had to find another way.

I’ve looked at what kinds of methods the class UmpleElement has and noticed that there is a method called getExtraCode() which returns the code associated with the Umple element and am going to use this function as a test for checking if an UmpleElement has any code inside which would mean that the element needs to have code generated for it and not skipped over. If getExtraCode() returns the empty string then the UmpleElement is most likely an external definition but if it doesn’t then code should be generated for the current element. I am currently at the point where I am about to test my modification.

February 26, 2013

I’ve been working on finishing a patch for issue 337 (on Google Code) which would make Umple generate an error message when trying to create an interface with an invalid name, as well as generate a warning message if an interface or class name starts with a letter that is not capital. The changes I made worked fine and the correct warnings/errors were generated when I manually tested some test cases but I noticed that when I ran a full build and checked the results of the JUnit tests that an existing test for something to do with StateMachines was failing.

When I looked at what was causing it to fail it happened to be that the warning message for a class not starting with a capital letter was being generated before the warning that the test was designed to look for so it was causing it to fail (as the name of the class in file that this test was using started with a lowercase letter). Instead of trying to fix this issue right away I decided to comment out the code I added to check when a class name starts without a capital letter and make sure everything else I had done in the patch worked without causing other previously existing tests to fail.

Since everything else worked, I decided to just create a patch with what was working(invalid interface name checking, warning when first letter of an interface name isn’t capital) because it goes against test-driven development guidelines to break existing tests when adding new code.

The main places where I made modifications to the code in this patch were in the analyzeClass(...) and analyzeInterface(...) methods in the UmpleInternalParser_CodeClass.ump file. I was able to determine this location as the right place to make the changes by looking at comments from the previous students that worked on a different part of this issue.

February 17, 2013

As I was making the modification to UmpleInternalParser_CodeStateMachine.ump class I came across some difficulties when trying to generate the error message for issue 354 (on Google Code). To explain what I had trouble with I have to first explain how I was going about checking if a state machine had the same name as an attribute or association.

The first thing you have to do if you want compare names between 2 objects is to start gathering the names of all the objects and checking to see if one matches another. This was done by having 3 lists, one for StateMachine names, Attribute names, and Association names. After figuring out how to create these lists you need to insert code that will check if two names match, which in general is done by using the function ‘.contains(name)’ on a populated list of names. If this function returns true, then an error message needs to be generated using either the function ‘addErrorMessage(...)’ or ‘setFailedPosition(...)’. The arguments for both of these functions require a Position object as one of the arguments in order for Umple to know where the error occurred when parsing, but the problem was that only Association objects had a ‘getTokenPosition()’ method which returned the Position of the Association. This meant that when checking if a StateMachine name was the same as an Association name I was able to get the Position object, but when checking if a StateMachine had the same name as an Attribute, I wasn’t sure how to obtain the position of one of these object to send to the error generation function.

Finally I saw that there was a HashMap object in the class I was working in called ‘stateMachineNameToToken’. Using this I could turn the name of a StateMachine into a Token object, and then from the Token I could get the position using the ‘getPosition()’ method. Doing this solved the problem of not having a Position when generating the error message and resulted in the code working correctly.

Another thing to note from working on this issue is to be very careful when editing the en.error file! I mistakenly put a comma where a colon was supposed to go and I couldn’t figure out what was causing all the errors when I tried to build Umple until Tim pointed out to me what I had done.

February 12, 2012

I am currently in the process of fixing issue 354 (on Google Code). So far I have created test cases which will test for duplicate names between state machines and other state machines, state machines and attribute names, and state machines and association names. I have also modified en.error to include a new error message (#52) which will be generated when this duplicate name issue occurs. Then I modified UmpleParserTest.ump to include the assert tests which are commented out for now.

Now I am onto the main part of fixing this issue which deals with modifying the UmpleInternalParser_CodeStateMachine.ump class. I determined it was this file I need to modify after looking over some other internal parser files and finally realized this was the one that deals with state machines (although it’s pretty obvious from the name!). The method in this class I have modified is postTokenStateMachineAnalysis() which will include a check for state machine name conflicts. It will do this by calling the checkStateMachineNameConflict() method which I have added to the class. I am at the point where I am ready to write the code in this method that will check for duplicate names between state machines and attributes/associations/other state machines and generate error message #52.

Feb 10, 2013

Time really does fly by because it feels like just yesterday when I submitted my last patch. I really wish I could devote much more time to working on Umple and I am considering the possibility of continuing to work on it this summer if I am not doing too much (when I don’t have 3 other classes and a thesis to think about as well).

Today I am looking at the 2 other issues currently assigned to me. Issue 337 (on Google Code) deals with generating error messages for invalid class/interface/external declaration names. In particular I am going to be focusing on generating error messages for invalid interface names such as “aaa&bbb”, invalid external association declarations which allow for the association attribute variable to be called invalid words such as “aaa&bbb”, and also a warning should be generated when a class name does not start with a capital letter.

Issue 354 (on Google Code) deals with naming conflicts which I had actually dealt with and fixed a lot of them in issue 272 (on Google Code). All that really remains in this issue is to fix state machine name conflicts with attribute names or association role names which should be simple enough as long as state machines are easy to work with in the umple code.

Feb 5, 2013 (Update and possibly helpful patch-creation walkthrough?)

This log post is going to cover a lot since I’ve been out of commission the last week due to knee surgery. I haven’t been able to move much from my bed/couch but luckily I could still get some work done on Umple on my laptop over the past few days. I have been working on issue 272 (on Google Code) (generating error messages for duplicate names from associations and attributes) and have just completed it and submitted a patch to Dr. Lethbridge.

In total for this patch, I ended up creating 30 different test cases and modifying the files UmpleParserTest.java, en.error, and UmpleInternalParser_CodeClass.ump. For the 30 different test cases I made I learned something very important which means I probably did not need to make 30 different test cases. When dealing with associations, Umple supports all possible variations of multiplicities so I wanted to include in my test cases the variations of these multiplicities which included: exactly one instance (1), zero or more instances (star), one or more instances (1..star). Just using these three multiplicities alone you can see how many variations there could be for an association from one class to another, and on top of that I had to account for unidirectional and bidirectional associations, as well as associations declared in a separate code block (not inside one of the classes). The thing is I am trying to fix the issue where the association names are the same as an attribute name so in retrospect I probably did not need to try all the different multiplicities because I thought they would make a difference. I probably could have gotten away with less than 10 cases.

I also learned that when you have an unnamed association that is singular, when Umple generates code it creates the name of the association as the lowercase of the name of the class the association is pointing to. When an unnamed association is plural, as in a multiplicity of 1 or more, Umple creates the name of the association as the lower case of the name of the class it is pointing to plus an extra ‘s’ at the end. This was important for writing some of my test cases.

Ex. This would create the association named “xs” in class Y. So I created an attribute in class Y with that name.

class X {

(star) <- (star) Y; // Pretend (star) is the star symbol which represents 0 or more. When i type the actual star it doesn't show up. }

class Y {

xs; }

Enough about test cases though. This was the first patch I really made on my own so it was a huge learning experience which taught me a lot. Once the test cases were done, I modified the UmpleParserTest.java file to include the assert tests which there were 30 of them in total (for the 30 different test cases) which checked to make sure the correct error message was generated when the error from issue 272 (on Google Code) occurred. Initially the assert tests were commented out since they would fail at first if I tried to run them. Now I was able to modify the code in UmpleInternalParser_CodeClass.ump to include the code to actually generate the error message when the error was detected. This took a little bit of work to find which function to edit and how to make the modifications but ended up being pretty straight forward. After this, I had to make sure to modify the en.error class to enable error message #23 which is the one I was generating for this issue.

Now that all the modifications were made, I was able to uncomment my 30 assert tests and run a full build of Umple. The build was successful which was good but I needed to make sure the tests were not failing and you cannot rely on just a successful build to do this. I looked in the index.html file located in the code\dist\qa\cruise.umple directory for my test results. The first time I did this I had a couple errors in my code which I had to fix, but finally there was no errors and this means the error messages were correctly being generated and the issue I had been working on had been solved!

Now I was ready to make a patch, which I learned all about because before working on Umple I had no idea what a “patch” even was aside from the general definition of patch which is to fix something. I learned about the technical details of how a patch is created and how the .diff files work and then I created a patch for all of the files I modified and added. Then I sent this to Tim!

I hope this walkthrough can give a somewhat better understanding to anyone unsure of how to go about making a patch for an issue, because I sure didn’t know what I was doing before this.

An interesting note to point out is that I did not use eclipse at all during this process. The main disadvantage I found was that I couldn’t find an easy way to find out what functions I could use on objects. For example I had to work with an object of type UmpleClass but I did not know what accessor functions I was able to use so I had to look at other previously written code to see what kind of functions were being used on this type of object in order to find the correct function to use. Luckily I didn’t have to look far but it would be nice if there was documentation which listed the functions for the different classes in Umple. Tim has told me that I can generate JavaDocs to obtain this information which is one way to obtain this information.

Jan 22, 2013 (Code sprint recap)

First of all I would like to say the code sprint at Facebook was an amazing experience both for working on Umple and meeting people/enjoying California.

So what did I get done over the past weekend? To start off the day friday morning I realized that I needed to install php and ruby on my machine and add them to my PATH variable in order for the full build of umple to complete successfully. This along with a minor problem with ant was causing the build to fail so this was the first thing I spent my time on fixing.

After the build was working it was time to start working on an issue so I finished issue #333 (on Google Code) which involved modifying an UmpleOnline example. Very basic stuff but it still needed to be done. I didn't have to create test cases for this issue and therefore was a really quick fix. After this issue was done I was messing around with umple and trying to run the full set of test cases using the command ant -Dmyenv=wlocal -f build.umple.xml template.test and noticed that ALL of the tests were failing. This was a pretty big problem because how would I be able to work on issues where you need to create test cases and run them if all of the existing test cases are failing in the first place?

This problem was solved eventually right before the code sprint was over by checking out a whole new trunk, running a full build, and then running the tests which were successful. Now I should be able to create my own test cases for whatever issue and be able to test it from the command line to see if they pass or fail.

Besides all the problems with windows/eclipse throughout the weekend the next issue I have started to work on is issue 272 (on Google Code). This issue deals with generating error messages for attributes and associations that have the same name. It seems like a decent amount of work because there is at least 6 or 7 different cases to test so my first task is to make a list of all the different cases and then write tests for them (in the UmpleParserTest.ump file) which will initially be ignored so that they don't fail. Then after that is complete I will be modifying the UmpleInternalParser_CodeClass.ump file to add code which will generate the correct error message (E#23 I believe) when a duplicate name is detected. After this modification is done I can un-ignore the Assert tests in UmpleParserTest and run all of the umple tests to see if they pass.

This last paragraph is more of a guideline for me to work through finishing this issue but if anyone sees anything wrong with my logic let me know.

Other things accomplished over the weekend was reading more about the Umple architecture and getting more of an understanding of how to create/apply a patch which I am looking forward to practicing this once I finish issue 272 (on Google Code).

With all of the problems Windows is giving me and the difficulty of solving problems that come up I would recommend to anyone thinking of contributing to Umple to set up a Linux based machine because you will have less problems and more help for the problems that do come up.

January 13, 2013

Before starting to think about how I'm going to contribute to Umple I need to learn more about how the language works so I'm messing around and trying to understand what's going on when I generate Java code (using UmpleOnline for now) after doing sample problem 0b from http://code.google.com/p/umple/wiki/SampleModelingProblems

After generating the java code, I downloaded the .zip and tried compiling and running it to see if it worked and the first few times I had minor errors but eventually I got it working by fixing my umple code. Something interesting I noticed is that if there is a 1-to-1 association between classes it really matters how you go about initializing instances of those classes. For example in my Tester class I tried to create an instance of a Coach and then create an instance of a SkiCourse which referenced the coach but that didn't work because the constructor for the class Coach requires a SkiCourse... which is hard to provide when there isn't any created yet. What I ended up having to do was get rid of the instance of Coach altogether and just create a SkiCourse which in the constructor had a "name" and "phone_number" which represented the coach of that course.

The code which I ended up with is here: http://cruise.site.uottawa.ca/umpleonline/umple.php?model=130114294055 I commented out the Coach variable that I was talking about. Feel free to mess around with the code if you'd like. If you generate the java code it should compile and if you want to see the results you just need to run the Tester file.

January 7th, 2013

I've just finished setting stuff up for Umple on both computers I will be using to work over the next 4 months. I've set up the eclipse development environment on my laptop(Windows Vista 32-bit) to use during the code sprint and as well on my desktop(Windows 7 64-bit) which will be what I am mainly working from. I wasn't sure it was going to work on Vista but everything seemed to go smoothly and none of the junit tests failed. To set up my environment I just followed the steps here: http://code.google.com/p/umple/wiki/DevelopmentSetUp

On a side note, during Step #5 I tried to "use umple to generate all .ump source files" in eclipse but when I did that many errors appeared, I'm not even quite sure what is fully meant by generating all of the .ump source files. Instead, at step #5 after I built and cleaned my project I compiled the file Master.ump from the command line using the command: java -jar umple.jar cruise.umple\src\Master.ump and then refreshed eclipse and ran the junit tests which worked fine.

Also I've installed ant and messed around with building umple from the command line and everything seems straightforward with that if you follow the directions in the development set up page.

One of the things I haven't done yet is install PHP because I'm kind of unsure how to go about it and what version to install because it seems like there are different uses for PHP according to: http://php.net/manual/en/install.general.php

Other than that I did the sample UML modelling problem (question 0a) using UmpleOnline and compiled the umple code on the command line using the umple.jar and also the resulting java code using the command java -jar umple.jar file.ump -c -

One weird thing I’d like to point out is after running the junit tests which gave no errors or failures, I opened the Master.ump file in eclipse and right after I did that a whole bunch of errors appeared in many of the files in the test, test/data/AfghanRainDesign, and src directories located in the cruise.umple project. All of the .ump files in src have errors in them. If anyone knows why this happened let me know!