Movin’ On

I have now completed one whole week in my new company. Looking back, I ask myself: “Why did I go out of my previous company?” That company was one of the best companies I have ever worked. I did not regret working there. The people were very nice, especially my bosses and my teammates. I had a lot of mentees there and I hope I have taught them enough, for them to be able to be successful in their work. I also created a lot of initiatives in that company, one of them is the Dining Philosophers. One of my mentees and teammate, Enjelica Pastoral, organized the Dancing Philosophers, an idea which came about during one of our team snacks.

So why did I have to move on, in spite of the very good position I had in that great company? There are many reasons, but maybe I can just offer the words of Ray Hannisian in the song he wrote entitled “Movin’ On”.

This was my elementary school graduation song which I never forgot because I like the lyrics and the song itself. I searched for a long time over the net for the lyrics of this song. I found one from this thread http://www.mudcat.org/thread.cfm?threadid=12043 and if you scroll down, you’ll see this link http://www.jwpepper.com/pdf/0786335.pdf. The lyrics is incomplete though.

“there is a voice, that has no name,
it comes with evening or behind the rain.
I have no time now, to stop and explain,
I just keep moving, cause it helps to ease the pain.
The night has music, that calls to me,
across the canyons of an endless sea.
I seek the shadows of yesterday.
I just keep moving, cause it helps to ease the pain…..”.

There is an air of melancholy in this song which says that moving on is hard and a sad thing, leaving the comfort of your current status and facing something entirely new and uncertain, something which to a certain degree scary.

The song ends with the following lines:

Speak to me softly but tell me no lies
I see tomorrow shining in your eyes,
I have no time now to stop and explain
I just keep moving cause it helps to ease the pain.

I echo this to all my mentees: I see tomorrow shining in your eyes. I hope our paths meet again.

Here’s a video from youtube so that you’ll get an idea of how the song goes: http://www.youtube.com/watch?v=7acCkbj4sOo

Advertisements

Dining with the Javaeros And Attending the MSP

Yesterday, the javaeros regrouped in Mannang, Mega Mall. One of the members, Aurelio Pascual, surprised us by showing up. Aurelio has been working in Malaysia since November of last year.

Most of us now belong to different companies, but the passion for learning is what unites us. We will have our next meeting on May 31 in Wendell Encomienda’s place. There we will be having a session on Parallel Computing.

img_0048.JPG

After that, I went to UP to attend the Mathematical Society of the Philippines conference. There we presented a paper on Differential Evolution using Python. Here is my friend Ernie Adorio who presented the paper:

pic-0115.jpg

This next one is Lorna Almocera of UP Cebu, Auggie’s friend and Arvin Cando’s teacher in the university.

pic-0118.jpg

She’s presenting the dynamical systems properties of HIV.

Dining Philsophers Meet Javaero

The future of Dining Philosophers now rests in the remaining core group. I will be moving on and re-start the group Javaero, which is the parent group of Dining Philosophers. Javaero means “lover of Java”, the Java programming language. Initially the group was composed of friends, from different companies, all of which are Java programmers. However, since we don’t only discuss java but also other languages and technologies, the Javaero word has come to mean “coffee lover”, the hallmark of a true programmer, don’t you think? This explains the coffee beans in our site.

dsc_4332.JPG
The photographer, Roli Balicas, is always at a disadvantage. So I’m posting another picture with him in it.

dsc_4334.JPG

The Dining Philosophers (or DP was we call it ) has been in existence for more than a year now in my previous company. The goal of DP is to find the best people in the company who have the same aspirations as us to discuss and learn about computer science and information technology. I am hoping that my core group will continue what we started and that Javaero and DP will merge in order to bring more expertise to the group.

Using MDA

Some things are just not easy to familiarize. One of them is using the AndroMda tool to design and build applications. This is a set of notes I made for my own purposes so that I can remember what I did that worked. And I hope you will find something useful in it too.

I am using MagicDraw as my uml tool because it the one highly supported by AndroMDA. The steps that I am following is in the excellent Getting Started Guide on java. When doing these notes, I am doing an Out of Office tracker tool. So the name of my project is ooo. After generating the project using maven, I need to change the model.uri to file:${project.basedir}/src/main/uml/ooo.uml2 because the default does not work.
After opening the model at mda/src/main/uml/ooo.xml I created the model named “ooo model”. In this model I created the root package of my project “org.javaero.ooo”. The first thing to do is to create the business objects. So I create a package under “org.javaero.ooo” called model and created a new class diagram. Here is the screenshot of my model class diagram.

model.jpg
The mistake I commonly make is forgetting to put the stereotypes in my business objects. In the diagram above, the User class will end up as an entity bean because of the stereotype “Entity”. The class UserVO is a value object and is the object being shared between presentation layer and the business layer. This should also be labeled with a stereotype or else you will not find this generated by AndroMDA. The dependency from User and UserVO object means that in the code that is generated there will be a method to convert from the User entity to UserVO.
Under the package “org.javaero.ooo” i created another package called “service”. This will contain the service objects that will have access to the User entity through the UserDao. The UserService is the service pojo that will have access to the User entity using the dependency from it to the User class. When AndroMDA generates the code, it will give the UserService access to the UserDao where you can manipulate the User entity.
service.jpg

My UserService class has two methods namely addUser() and listUsers(). When AndroMDA generates the code, it will create a class called UserServiceImpl under the folder core/src/main/java. See the screenshot below:

servicecode.jpg

You need to open this class and provide implementation to the methods handleAddUser() and handleListUsers().

Now it’s time to put an interface to our new ejb. I added a new package under “org.javaero.ooo” called “web”. This will contain the use cases of the web interface. For each use case, i’m going to put it under a new package under “web”. Now i’ll create the use case called “Add User” and a state machine diagram that will contain the state machine for this use case. I have to put this under a new package called “adduser”. Here is the state machine diagram:

statemachine2.jpg

Never forget to put the initial state. The stereotype “FrontEndView” that labels a task means that AndroMDA will render this as a view in struts. Imagine the user entry page as containing two text fields named “First Name” and “Last Name”. The page will submit this two parameters to the server. We can model this using the transition from User Entry to Add User. Right click on that transition and open the specification. Click on the behaviour type of “Entry” and specify Activity. In the containment tree, click on this behaviour and add parameters “firstName” and “lastName” with datatype as String. Add the tag @andromda.presentation.web.view.field.type = text to these parameters. See the screenshot below to get a hint on how this is done.

addparameters2.jpg
The screenshot below shows how to set the tag @andromda.presentation.web.view.field.type to “text”.
Setting tags to render it in correct html input objects.

By specifying the tag @andromda.presentation.web.view.field.type as “text” , this will be rendered as an html text field.

Now that we already have our input page, the next thing to do is to create a controller that will accept these parameters and save them to the database. Let us create a new class under the “Add User State Machine” and call it UserController. To do this, just right-click on “Add User State Machine”->New element->Class. Name this class as UserController.

usercontroller.jpg

On the containment tree, right-click on UserController and open its specification. Create a new operation on it with signature addUser(String firstName, String lastName).

usercontroller-operations2.jpg

Now that we have our controller ready, click on the “Services” class diagram and from the containment tree, click on the UserController class and drag it to the “Services” diagram. Create a dependency from UserController to UserService class. This will allow UserController to access the UserService.

usercontroller-userservice.jpg

Now, let’s go back to the “Add User State Machine Diagram” and model the interaction of our state machine with the UserController class. Click on the Add User task and open the specification. Specify the behaviour type of Entry as Activity. In the containment tree, click on this activity and open it’s specification. Click on Node and click “Call Operation Action”. This will take you to the “Call Operation Action” specification. Click on “Operation” and choose addUser() operation from UserController. As you might have guessed, this will invoke the operation UserController.addUser() which we should implement.

calloperation1.jpg

Generate first the classes using the command “mvn install”. Then find the class UserControllerImpl and implement the “addUser()” method. Notice that method signature of addUser is different from what we specified above. Instead it’s method signature is:

public final void addUser(ActionMapping mapping, org.javaero.ooo.web.adduser.AddUserForm form, HttpServletRequest request, HttpServletResponse response) throws Exception;

The parameters firstName and lastName can actually be found in the AddUserForm. Here is a simple implementation of this method:

adduser-impl.jpg

Now it’s time to generate the tables in mysql using the command “mvn -f core/pom.xml andromdapp:schema -Dtasks=create”. You can verify that the table is created using mysql client:

mysql.jpg
To deploy the application, we issue the command:mvn -f app/pom.xml -Ddeploy

This will deploy to jboss directory. It will be a good idea to start jboss before deploying so you can see the deployment in action. After deployment, you can access the application by launching your browser and pointing to http://localhost:8080/ooo. Here is the screenshot of the page:

first-page.jpg

Finally, put some values into the two fields and submit them. Check that the values indeed end up in the database.

mysql2.jpg

Talk on Parallel Computing

Parallel computing used to be the province of scientists and engineers. The tools and algorithms to do this has always been available on the net. However, since the advent of multicore machines, there is now a compelling reason for all programmers to learn and master it. Parallel programming is already the future of computing and there future is now.

I remember way back in 1998, I was introduced to parallel computing in MPI. I also wrote some papers on parallel algorithms and still active in parallel algorithms research. Now I am advocating and teaching a lot of people in parallel computing.

dsc_4057.JPG

Celebrating Labor Day

It’s labor day and what a fitting way to celebrate Labor day than to work!

First order of business today was to setup the MPI (Message Passing Interface) and demo programs in my computer. Since MPI is a shared-memory distributed computing platform, I need to set it up also in another laptop. I’m glad my friend Roli Balicas agreed to let me setup his laptop. He spent about 5 hours in our house. It does not really take a long time to setup MPI in two dual-core laptops. We just spent most of the time eating pizza from Pizza Hut and watching Jet Li movies. We were able to watch two full movies while I was also setting up MPI on the two laptops.

Roli’s laptop was running Ubuntu 7.10 and is not yet configured as a developer’s laptop so I had to install xorg developer packages in order to make the MPE of MPI compile with X enabled. After upgrading his laptop, I was able to recompile MPI and compile the Mandelbrot demo. Now the two laptops can run the demo.

After Roli left, I went back to my experiments on Model-Driven Architecture. I’m looking at AndroMDA, an MDA generator and MagicDraw as UML tool. I’m enjoying my explorations into this subject. However, MDA seems to have a bleak future. A lot of heavy-weight personalities don’t see any future on MDA. See for example this. Whatever may be the case, the fact that i’m enjoying it is already enough for me.