Tuesday, November 4, 2008

Clean Code

Now that my team is working on some big and exciting development tasks for our Eclipse-based product, there is no better reading than Clean Code by Uncle Bob, the book that the Toronto Design Patterns Study Interest Group has chosen to read for this season.

Currently, I am working on a task that involves consolidating the model for our business process editor. Due to the adoption of GEF, our product has been running with two parallel models, a new one based on GEF and a legacy model that does not follow an MVC architecture. As a result, there is a lot of code duplication and dead code.

While I am working on the task previously mentioned, I have found how easy is to write bad code. Although, it is not hard to write clean code as a personal activity, it is harder to provide a sustainable policy for improving existing code as a collective activity. A fundamental rule in this policy is nicely described by Robert Martin’s book. In Chapter 1, he makes reference to the Boy Scout Rule: “Leave the campground cleaner than you found it”

In conclusion, the key point is not just to write clean code, but to polish existing code and leave it cleaner than how we found it. The benefits and advantages of clean code are widely discussed in the book, however my suggestion to you is to not commit code to your versioning control repository if your changes do not leave the code cleaner than you found it. Believe me, it will make your professional life easier.

Feliz coding,

Friday, August 29, 2008

Eclipse Copyright Tool

The other day I tried the Copyright Tool, part of the Eclipse Releng Tools (org.eclipse.releng.tools) however I could not find documentation for it.

I was trying to update the copyright statements in our source code so I modified the copyright template in the preference page. Then I ran the “Fix Copyrights…” action and the copyrights changed but not with the text I specified in the template. Then I found this thread in Eclipse newsgroups explaining the difference between the "Fix Copyrights..." and "Advanced Fix Copyrights..." actions. The action that updates the copyright statement with the text in the template is “Advanced Fix Copyrights…” and it is available only in the Navigator view!
At the end, after playing a bit with it, I found this tool interesting but not useful for our specific case; it needs to be more customizable.

Hope this posting gives you some heads up…

Puzzle for killing your brain cells

A friend of mine sent me this Fantastic Contraption puzzle. Good one if you like thinking.


Tuesday, August 26, 2008

Debugging WebSphere with Eclipse

This is how I attach my Eclipse 3.3 to WebSphere 6.1 for debugging my deployed applications.

In WebSphere’s console, I go to Application Servers > my-server-to-debug > Java and Process Management > Process Definition > Java Virtual Machine. Near the bottom of the page, I check Debug Mode and the values I am using in Debug arguments are:
-Djava.compiler=NONE -Xdebug -Xnoagent

After applying the changes, I restart WebSphere.

In the Debug Dialog, I create a new configuration under the category Remote Java Application. I specify the project containing the source code of my deployed application, localhost (my WebSphere is running locally) and the port 7777.

Now I am ready to debug. I add some breakpoints, launch the debug configuration and run my deploy application.

Hope this helps you.

Until next…

Monday, August 18, 2008

Java Certifications

Here is a nice article with a list of different Java certifications available (not just from Sun): http://java.dzone.com/articles/certifications-may-i-see-the-m

Right after finishing my Computer Science degree, I pursued my SCJP certification and although it was not a guarantee for a job, it definitely gave me an advantage over other candidates.

Whether if the certification made me a better programmer or not, I am not sure. However, I noticed that the certification gave me extra knowledge that my programming classes did not teach me and that my colleagues did not know.

After a few years programming, I realized that good programmers are made of experience, knowledge and creativity, not just certifications or good grades at school.

Until next…

Thursday, August 14, 2008

Eclipse blog en Español

After some incredible vacation, I am back.

While I was doing a short research over the internet, I found out that there aren't many Eclipse blogs in Spanish. Therefore, I will start one.

I will continue posting all my entries in this blog. However, for those entries about Eclipse, I will translate them and post them in the new blog. Stay tune for the next entry...

Hasta la próxima...

Monday, July 21, 2008

Open-Source economics

I came across a video talk from Yochai Benkler about the next step in human organization: open collaborative projects. He mentions Wikipedia as an example, but I would like to include Eclipse as well.

You can find the full talk in TED.com.

Wednesday, July 16, 2008

Demo for Ganymede's security

Hi All,
Security is one of the features I was waiting to see in Eclipse and I am glad that Ganymede comes with it.

I found a good introductory demo in Eclipse Live that explains the new security features: http://live.eclipse.org/node/565. The demo is pretty clear and gives an overview of how security works in Ganymede. Don't forget to visit Equinox Security website for more info.


Friday, July 11, 2008


Recently I’ve been guiding our off-shore team on moving our pop-up menu actions from using org.eclipse.ui.popupMenus extension point to a newer mechanism. Eclipse 3.3 provides a new mechanism, a lot easier to use, through the org.eclipse.ui.menus extension point. This extension point adds UI contributions to the main menu, main toolbars, view menus, view toolbars, context menus, etc. and replaces the following (legacy) extension points: org.eclipse.ui.ActionSets, org.eclipse.ui.EditorActions, org.eclipse.ui.popupMenus (including 'objectContributions') and org.eclipse.ui.viewActions.

Below is a summary of the steps for migrating to the new mechanism. Since there are a number of pop-up items, the migration converts one action at a time. Here are the steps:

1) Contribute a command using org.eclipse.ui.commands extension point.
2) Refactor the action delegate class to a handler delegate class.
3) Contribute the converted handler class using org.eclipse.ui.handlers extension point and specifying the command from step 1).
4) Then, add the command to your particular menu using org.eclipse.ui.menus. Here the trick is specifying the locationURI. For example: locationURI="menu:org.eclipse.ui.main.menu?after=additions" adds a command to the main menu and locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions" add a command to the main toolbar.

The org.eclipse.core.commands.ExecutionEvent in the new handler’s execute(ExecutionEvent) method can be passed to class org.eclipse.ui.handlers.HandlerUtil. HandlerUtil provides static methods for obtaining the context when the command is executed, such as the shell, active editors, parts, menus, etc.

After testing the conversion of the old actions to the new mechanism, the next step may be adding key bindings by extending org.eclipse.ui.bindings. Remember to specify a sequence that has not been bound already.

Another consideration is enablement, as some commands may not be available all the time. Method isEnabled() in the new handler may be overridden, but when this method is called it is not possible to obtain the active editor. In cases when the user enables or disables the action through a preference page, method isEnabled() may be used. An approach to enablement is as follows:
1) Create a property tester using org.eclipse.core.expressions.propertyTesters extension point
2) Add the clause enabledWhen in org.eclipse.ui.handlers extension point and test for the above property, for example:
... inside a given extension point



May be used for testing that a selection (like a resource) has a particular property, that is command may applied to the selection.

At this point, the conversion should have gone fine. I hope this post helps you as a reference.

Until next…

Friday, July 4, 2008


For the past couple of days, I've been trying Ganymede, the new Eclipse 3.4. So far, there are good things that I like, but there is one issue that made me go back to 3.3. First, the good things.

One of the nice features is an improved Javadoc hover. As a plugin developer, this feature has provided me with better access to Eclipse API. Also, the Javadoc hover shows the value of constants, but this shows how the constant is initialized, not its runtime value.
Another feature I like is marking read and write occurrances, giving a hint of where variables are being modified or just read.

The issue I am experiencing is with my Java EE environment. I tried to migrate my workspace from Eclipse 3.3 to Eclipse 3.4 and got the following errors in one of my "ear" projects:
- "IWAE0053E An internal error has occurred running validation on project:TheProjectEar]:TheProjectEar, check the log file for details"
Followed by errors like these:
- "The deployment descriptor of the module 'TheProjectEjb.jar' cannot be loaded."
- "The deployment descriptor of the module 'WebTheProject.war' cannot be loaded."

I haven't found a solution or an explanation yet, however when I switch back to Eclipse 3.3, I don't see this error anymore. As soon as I find what the problem is, I'll post my findings.

Until next...


This is not my first blog, but the one I had before (Yahoo 360) wasn't visible through a Google search and I stopped updating it.

I am a software developer with experience in plug-in development using the Eclipse platform and Java EE. Also, I have special interest in software improvement, coding standards, techniques for improving development, etc. My intention is to share my knowledge and thoughts through this blog.

Hope you find it helpful.