Subscribe: My Own Digressions
Added By: Feedage Forager Feedage Grade B rated
Language: English
bundle  code  eclipse  emf  file  integer  new  option save  option  platform  resource  time  uri  work  working  years 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: My Own Digressions

My Own Digressions

Ideas, rants, comments, and... well... digressions.

Updated: 2017-07-08T03:37:54.752-04:00


Talk for EclipseCon 2012


Since I am back to the world of developing tools for Eclipse developers, I thought it would be interesting to propose a talk for the North America edition of EclipseCon. As for the subject of the talk, I chose to share some of the knowledge I gathered between 2008 and 2011 while using linked data and RDF on a few projects at IBM.

The talk has a catchy name: I cheated on EMF with RDF. And I may do it again!. If you are interested on hearing this confession, vote for it. Moreover, if you are really, really interested, please leave a comment with your expectations and even the topics you'd like to hear about. I won't be able to put 2+ years of hands-on experience with RDF in a 35 mins talk and would hate to leave behind something that a lot of people are interested just because I don't know they are interested ;-)

That said, the greatest thing about EclipseCon is that the technology sharing experience is not limited to the presentation rooms. If I am there, I will be more than happy to discuss this and any other topic, especially while having some drinks at the bar ;-)

There is a world of statements out there


People that work with me have certainly heard "wow, I was smart" more than once. Typically I use this sentence when I am puzzled trying to understand some beautiful code I've written or designed a while ago. Now I am afraid that one day I will be saying it a lot if I ever need to look back at the technologies that I was focused on during my last years at IBM. Since 2009, I've been head down understanding the main pieces behind linked data:

I have to confess: these technologies are fantastic! Out of them, the one that I like the most is certainly RDF, probably because it's in the realm of models. Honestly though, I had a hard time understanding it at the beginning for I was seeing it with my old, schema-driven eyes. You know, for more than 15 years I trained myself to see the world as instances of rigid schemas, mainly formed by classes, attributes, and references. Alas, this way of thinking doesn't go well with RDF. If one is like I was, I'd suggest repeating "RDF is not just a new way to express a schema" at least every five minutes while trying to make some sense out of it.

My plan is to use the free time that I happen to have now to write down my thoughts about these technologies. Hopefully I will be able to register here what I refer to as my "linked data intuition": the small pieces of knowledge that I've assembled from various sources and that I now use to tackle any new RDF or REST challenge. For a second I've considered writing this on a personal document and store it away for future reference. How dumb is this? Putting the words here may benefit others and even allow people to correct me. Albeit pretentious, I like to believe that I know the stuff I am about to write ;-) But I wouldn't be surprised to be proven wrong. And that would be actually great: that's when one has an opportunity to reset and reflect about a topic again.

Looking forward to spending more time here in the next few days.

A new life ahead


It has been a while since I've written something here. Either by laziness or my notorious capability of ignoring the social media aspects of today's world, I know I have completely abandoned this blog.

What made me take the time to post now, then? To share that after 10+ years I am no longer an IBMer. It was a very hard decision and at the end the I've chosen what made sense for me and my family. At this moment I fell great, anxiously waiting for the start of my life. Honestly though, by the beginning of this week I was almost miserable: not for regretting the path that I was taking but to be taking it. It is hard to explain. IBM has been a second home, one that was opened to me just two weeks after I came to Canada. Oh well... I promised myself I wouldn't get emotional ;-)

So what lies ahead? In a few weeks I will join Oracle, working with the team that is creating the best Eclipse tooling for developers that have adopted Oracle technologies. Man, I am exited! First I will be back to daily interactions with my favourite framework and its related technologies. Second, I will have to learn an entire new world of enterprise-focused technologies! Lots of fun and hard work for the next months.

What a great EclipseCon!


As anyone on this planet knows, last week was EclipseCon time. As always, it was a great experience. Seriously... How many conferences can one discuss, during lunch, the double-checked locking pattern or how EMF could support facets? (thanks Eike and Kenn)

All talks I've attended were awesome. It's reinvigorating to see all the energy and technology happening behind Eclipse: from known technologies to hot topics like E4 and XText.

And it gets better! The people at the conference are simply fantastic. Just to name a few, it was great to chat with Nick, Chris, and Boris and to finally meet in person Tom, Kevin, Peter, and Paul Webster. There are many others that, although not listed here, have contributed to make last week a memory that will not fade away from my mind.

A bit more personal, I like to think that the EMF tutorial was well received. We chose to go deeper into several subjects instead of mechanically read all the slides. Unfortunately, because of that, we didn't cover all the material. The offer to be available to answer individual questions after the conference is still valid ;-)

I got some positive reviews for the modeled UI in e4 talk, which definitely doesn't seem to agree with the official numbers. I wonder if we were too "slide driven" while the folks attending were expecting to see more action. Or perhaps my delusional-self is correct and people did mistake the '+1' for the '-1' bucket. Oh well... I am sure we'll do better the next time.

Finally, a special thanks to Steve: I was peacefully seated at the closing event when he handed me a winning deck for Thursday's poker game. My son loved the RC boat and will enjoy playing with it on summer time.

Another finally... The EMF book was the first one to be sold out at EclipseCon! I had the pleasure to autograph a few copies. On the subject, EMF and modeling in general are everywhere. It is good to see something I helped built making others more productive ;-)

I am lazy!


It is annoying to feel compelled to start every post with "Wow... It has been a long time since I've posted something here". Of course one answer is "So don't". I'd rather think that some people would prefer to say "So post more". I am known for having an occasional delusional moment here and there, though ;-)

I believe one of the reasons that I don't update this blog as often as I wanted to, besides being insanely busy, is that, bottom line, I am a lazy person. Fortunately, a characteristic that would put me out of any work back 50 years ago, is actually something that should be rewarded on the software development world. Let me illustrate this with an example.

When I am heads down, working 15+ hours per day to develop an entire product or a complicated feature, I get extremely paranoid (way more than normal) about introducing regressions by entering a, or better, any new line of code. And testing everything all the time is too tiring (I started by saying that I am lazy, remember? ;-). So I usually choose to automate as many tests I can. Sure I have to invest some time putting together an automation strategy (usually based on JUnit). But after that, I just need to click a button and watch the JUnit progress bar go while I exercise the divine right of not doing anything for a few minutes - OK, I am lying: usually I am working on another portion of the code while the tests are running.

On my last endeavor, for example, testing the code consisted on executing 11 Java examples that invoke an API written to identify security issues on web applications by looking at their code and by interacting with them as a hacker would do. Each one of these Java applications run for about 2 to 10 minutes and produces a long log that has to be verified. After doing this by hand 3 times, my laziness kicked in and forced me to find an easier way to test my code. After one or two hours of JUnit fun, I had a class that, for a test method like the one below, executes the XYZ.class on a separate VM, collects the generated log, and compares it with a baseline I know is correct.

public void codeCoverageExample() throws Exception {

The comparison part was a bit tricky to implement because the logs have things like timestamps and temporary file paths that change from execution to execution. With some creativity and several regular expressions, I managed to circumvent all the issues and, like a famous black-turtle-neck-guy says, "BOOM" : the annoying tests were out of my way ;-)

I will write at least one more post pointing out cases in which being lazy was extremely valuable. I am already thinking about EMF related examples...

Actually, on a minor digression, is my passion for EMF the ultimate proof that I am lazy? After all, it does generate a bunch of the code that I would need to code by hand ;-)

"Ch-ch-ch-ch-Changes" and "I am still around!"


I couldn't really decide what would be the best title for this post. So I chose to use both ideas that I had in mind. Fortunately, as this title, there are several opportunities in which we can actually choose all the options that are presented to us. For example, three years ago, I've chosen to be both Brazilian and Canadian. More recently, I've also chosen to change a bit my professional life and do some product work while keeping my duties as an EMF committer.

After four years dedicating myself exclusively to EMF, I am now working on the Rational AppScan Developer Edition team (our beta is available here). A minor digression, the security-related technology behind this product is quite amazing. I really don't want to sound like a salesman, though. I know that it wouldn't go really well given my "amazing" commercial skills ;-)

The good news is that both Ed and my new manager (Jeff Turnham) have been extremely supportive in my decision of work both internally and on open source. Hopefully most of you agree with their attitude. I certainly do ;-)

To me it will be a bliss to employ the technology that I help build. Although the EMF team has always eaten its own dog food caviar ;-), it is quite different to face the problems that consumers of our code have to deal with. On the other hand, I am really expecting that the product experience will make me a better EMF developer. EMF has been part of my life for quite a while and it certainly deserves the best I can be.

Platform scheme URI


Wow... It has been more than six months since the last time I took a few minutes to write something here. Things have been a bit crazy lately. A lot has kept me occupied, like, for example, writing the 2nd version of the EMF book (which is "already" available as a rough cut), working on a few bugzillas, and supporting the EMF community. On a more personal note, in October we moved to our new house right when our son was entering the "terrible twos" days. Actually, since then, my wife and I have been working as maniacs to finish the basement and prepare the kids' rooms for the arrival of the new member of the Paternostro family, who is supposed to be here by the end of April.But I am sure you are not reading this to hear about what I've been doing ;-) So, let's move on to the subject of this post. Quite frequently people ask me how to "locate" files in Eclipse. In 80% of the cases, the conversation is about things like IFile and IWorkspace. Sometimes it digresses to files available inside bundles and, rarely, it involves the "state location" of a bundle (see the Plugin.getStateLocation() javadoc for more details). Obviously you can use IResources or to work with files in these places. There is another way, though: platform URI. Although this scheme has been around since the beginning of time, I decided to ramble about it here because I've never seem its uses described in one single place.There are a few ways to work with the "platform" scheme:platform:/resourceIt is used to identify a resource located in the workspace. The next path segment after "resource" should be the name of a project, which can be followed by the folder and/or file we want to locate.platform:/pluginIt is used to locate a resource available in a plug-in (I know, I know, bundle). One really cool thing about this one is that it doesn't really matter if this resource is available in a directory or in a jar file. It also doesn't matter if the bundle is installed in a link folder or in the default directory.The path segment after "plugin" should be the identifier of the bundle, which can be followed by the path of the resource in the bundle.platform:/fragmentThis one is quite similar to "platform:/plugin", being to used to locate fragment resources instead of bundle resources. As you are probably guessing, the segment after "fragment" should be the fragment's identifier.platform:/metaWe can use this to access a bundle's stage location. The path segment after "meta" should be the bundle's identifier, followed by the path of the resource we want to refer to.platform:/configThe "config" segment causes the platform URI to refer to the configuration area of the running Eclipse (usually the eclipse/configuration directory). This can be useful to read the config.ini file, for example.platform:/baseThis always refers to the directory of the Eclipse being executed.It is interesting to note that, for example, platform:/base/plugins/org.eclipse.emf/plugin.xml and platform:/plugin/org.eclipse.emf/plugin.xml don't necessarily refer to the same resource. The former is a "pointer" to a plugin.xml file located in a directory plugins/org.eclipse.emf under the directory that Eclipse is installed. The latter points to the plugin.xml of the "org.eclipse.emf.ecore" bundle regardless of where it is installed and whether it is jarred or not.For the URI-savvy people, you should see "resource", "plugin", "fragment", "meta", "config", and "base" as authorities. Perhaps they could become authorities in e4 (yey! Now this is an e4 related post ;-)Since we all like actual code...IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("myproject");if (!project.exists()){ project.create(new NullProgressMonitor());}System.out.println("\n==== platform:/resource ====");{ URI uri = URI.createPlatformResourceURI("myproject", true); System.out.println(uri); System.out.println(CommonPlugin.resol[...]

Almost there, mom...


Yet another month has gone and my perfect plan to blog about something cool in EMF every week didn't work as intended. If you check the date of my last post, you will see that it was written right on the last day of July. And here I am, last day of August...

Being honest, I can't even say that I've been busy doing development work. Other than a few bug fixes and time assisting users, most of my (and Dave's) days have been spent on the second edition of the EMF book. The good news is that we are really almost done writing the manuscript. And the material is looking great! We took the time to go deep on several topics and also to add much more content than what is available in the first edition. Just to give you an idea, the second edition will be at least as thick as the first one and it doesn't have the not so popular "javadoc" chapter.

Btw, if you were intrigued by the title... I was naive enough to tell my family and close friends about the book when we've started working on it, a looooong time ago. So now I am often hearing the inevitable question "when will it be available" regardless of where I am: at work, conferences, and, unfortunately ;-), BBQs, bars, ...

No more NPE when generating models


For most users, EMF 2.3 is all about Java 5.0. Although most of our time was certainly spent on Generics and other "5isms", we sure managed to implement a few nice features as listed in our release notes. BTW, I know that this report is not as beautiful as a "New and Noteworthy" page, but that's the best we can offer now. Note to Wassim: I promise we will try to improve for this release ;-)

Of these nice features, the one I think I like the most is the complete validation of Ecore models. Basically this work consisted on defining and implementing all the constraints that characterize a well-formed model using the EMF Validation framework. Without an automated way to check these constraints, aka "before 2.3", any poor soul manipulating Ecore models would probably end up getting all sorts of exceptions when generating the code for the models. In face of these exceptions, the users would do the simplest thing available at the time: post a question on the newsgroup and wait the excruciating 10 minutes delay that usually takes Ed to answer.

Now this has changed! To check if your model is correct, hence capable of being used for code generation, all you need to do is to either open the .genmodel file editor or, on the .ecore file editor, select a package and run the Validation action available in the context popup-menu. Any existing problem in your model will be then presented in a tree viewer, with (hopefully ;-) all the information you need to have it fixed.

I should mention that EMF 2.3 can validate any Ecore model. So even if you are using an older version of EMF and usually edit your Ecore models directly, I believe the model validation justifies having the 2.3 release installed somewhere in your machine.

I want my feature request implemented yesterday!


"What do you get when you put together a bunch of passionate developers and a code freeze policy due to the end of a release?" This is probably a good start for a Dilbert cartoon. Certainly Scott Adams' answer would be brazilian times funnier than mine, which is "crazy people implementing the cool things they want regardless of how beautiful the day is outside".

The "cool thing" I worked on yesterday was to leverage the pattern filter widget you see on Eclipse's New Project Wizard to some EMF dialogs. After some digging I was able to get the results I was looking for by simply using new FilteredTree(...).getViewer() instead of new TreeViewer(...). BTW, I would recommend reading the PatternFilter's Javadoc if you are considering doing the same in your code.

Everything was going smooth up to the moment that I've opened a subclass of org.eclipse.ui.dialogs.ElementTreeSelectionDialog. I couldn't believe what I was seeing: there was no way to replace the TreeViewer used by this class. Profoundly disappointed, I began to write a feature request for the UI team. As I was doing it, I thought that I would be a much better Eclipse citizen by providing a patch instead of simply describing what to do. So I checked out the "org.eclipse.ui.workbench" bundle, opened ElementTreeSelectionDialog, and added a new protected method that instantiates the TreeViewer. Before changing the line of code that would use my new method, I looked around to see how the Javadocs on the file are written. To my surprise I discovered this new method: ElementTreeSelectionDialog.doCreateTreeViewer(Composite, int). After blinking my eyes for a few seconds I realize that the method I need is already available in Eclipse 3.4. Amazing!

Kudos to the UI team.

EMF tips and tricks: Don't save if it hasn't changed.


For a while I have been thinking about writing some EMF tips that may not be known by most of the users. What keeps me from doing it is the lack of inspiration to come up with a nice introduction and to explain the rationale behind a design. This is probably silly though. I am sure I would be way more useful if I simply focus on showing the "what" and "how", leaving the long discussions for the cases when someone is actually interested ;-)

So here we go...

We've added a few new options to the EMF Resource in EMF 2.3 (the one available in Europa). One of them is Resource.OPTION_SAVE_ONLY_IF_CHANGED. When this option is used, the save method writes out the bytes of the serialized objects only if these bytes are different from the existing persisted form of the resource. Behind the scenes, the objects in the resource are serialized to either a temporary file or memory buffer and then compared with the bytes read from the URI pointed to by the resource. Clearly this slows down the save operation, but it may be useful when, for example, the resource serializes to a file that is versioned by CVS, hence avoiding "zero delta" changes.

This snippet shows how to use this option:
Map(object)  saveOptions = new HashMap(object) ();

Using OPTION_SAVE_ONLY_IF_CHANGED_FILE_BUFFER instead of OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER would serialize the objects to a temporary file instead of using a buffer in memory. This subtle difference is important when dealing with big resources.

An experienced EMF user may be asking how this relates to the Resource.setTrackingModification(boolean) method and to the "dirty" state of the editor generated by EMF. The main difference here is that the new option applies to the actual bytes of the serialized resource while the other two approaches are related to the state of the objects in memory. For example, the new option doesn't change the serialized resource when a "dummy" modification is made to an object (such as setting an attribute to its current value), but would do it if the serialization format changes (which could be caused by using a different value for the XMLResource.OPTION_LINE_WIDTH option, for instance). The other two approaches do the exact opposite in these examples.

From iterator-loop to foreach-loop with one regex.


Probably the most important feature we've worked on this release was to add Java 5.0 support to EMF. We've learned a lot during the process and actually had some fun trying to make sense out of Generics and Annotations. Of course there were also some very annoying tasks, such as converting Java 1.4 "Iterator loops" into the new "foreach loop" style. For example, this snippet
for (Iterator i = Collections.singleton(new Integer(1)).iterator(); i.hasNext();)
Integer integer = (Integer);

should look like this after the modifications
for (Integer integer : Collections.singleton(new Integer(1)))

Unfortunately Eclipse's "Source->Clean..." magic action doesn't do a good job here since it doesn't keep the names and types of the "each" variable. At least back in December, I would end up with Object object : instead of Integer integer : for the example above.

Either to boost my productivity or just to exercise the right to be lazy ;-), I've come up with a regular expression that does the conversion for me. It works flawless with Eclipse's Find dialog (ctrl+f):

Here's a clipboard friendly version:

Replace with:

I've been doing the same thing for over 10 years!


On a recent trip to Brazil, I had the unique opportunity to hear "you are so boring" from some close friends of mine. I like to believe they were talking about the fact that I've been working on "modeling", "code generation", and "development processes" for more than 10 years.

It all started in 93 when I read Rumbaugh's OMT book. Since then objects have been part of my life. I implemented (and sometimes managed) several projects modeled using UML and implemented using Java, C++, VisualBasic, and even Eiffel. Also, as a Rational consultant, my work activities were usually related to sell, demo, and teach Rose (not to forget requirement tools, functional testing tools, and whatever Rational had on its package).

Fast forward to 2007. Where I am now? For 3 years, since Jan 2004, I've been working on the coolest project ever: the Eclipse Modeling Framework (EMF).

Modeling and objects to the bone!