tag:blogger.com,1999:blog-10943885802792121352024-02-19T11:36:28.385-05:00My Own DigressionsIdeas, rants, comments, and... well... digressions.Marcelo Paternostrohttp://www.blogger.com/profile/05767041268062110476noreply@blogger.comBlogger17125tag:blogger.com,1999:blog-1094388580279212135.post-5012013789423512392011-11-14T09:29:00.001-05:002011-11-14T10:04:37.446-05:00Talk for EclipseCon 2012<p>Since <a href="http://lmap.blogspot.com/2011/05/it-has-been-while-since-ive-written.html">I am back to the world of developing tools for Eclipse developers</a>, 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.</p>
<p>The talk has a catchy name: <a href="http://www.eclipsecon.org/2012/sessions/i-cheated-emf-rdf-and-i-may-do-it-again">I cheated on EMF with RDF. And I may do it again!</a>. 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 ;-)</p>
<p>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 ;-)</p>Marcelo Paternostrohttp://www.blogger.com/profile/05767041268062110476noreply@blogger.com2tag:blogger.com,1999:blog-1094388580279212135.post-23250763924058489242011-05-14T13:52:00.016-04:002011-05-15T14:04:09.227-04:00There is a world of statements out therePeople 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 <a href="http://linkeddata.org/">linked data</a>:<br /><ul><li><a href="http://www.w3.org/TR/rdf-syntax/">Resource Description Framework (RDF)</a></li><br /><li><a href="http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm">Representation State Transfer (REST)</a></li><br /><li><a href="http://www.w3.org/Protocols/rfc2616/rfc2616.html">HTTP</a></li></ul><br />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.<br /><br />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.<br /><br />Looking forward to spending more time here in the next few days.Marcelo Paternostrohttp://www.blogger.com/profile/05767041268062110476noreply@blogger.com0tag:blogger.com,1999:blog-1094388580279212135.post-88052366869727403122011-05-14T13:15:00.004-04:002011-05-14T13:51:56.644-04:00A new life aheadIt 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.<br /><br />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 ;-)<br /><br />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 <a href="http://www.eclipse.org/modeling/emf/">my favourite framework</a> 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.Marcelo Paternostrohttp://www.blogger.com/profile/05767041268062110476noreply@blogger.com6tag:blogger.com,1999:blog-1094388580279212135.post-59261103784432209282009-03-29T19:12:00.015-04:002009-03-29T23:11:46.532-04:00What a great EclipseCon!As anyone on this <a href="http://www.planeteclipse.org/planet/">planet</a> knows, last week was <a href="http://www.eclipsecon.org/">EclipseCon</a> time. As always, it was a great experience. Seriously... How many conferences can one discuss, during lunch, the <a href="http://en.wikipedia.org/wiki/Double_checked_locking_pattern">double-checked locking pattern</a> or how EMF could support facets? (thanks <a href="http://thegordian.blogspot.com/">Eike</a> and <a href="http://kenn-hussey.blogspot.com/">Kenn</a>)<br /><br />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 <a href="http://www.eclipse.org/e4/">E4</a> and <a href="http://wiki.eclipse.org/Xtext">XText</a>.<br /><br />And it gets better! The people at the conference are simply fantastic. Just to name a few, it was great to chat with <a href="http://divby0.blogspot.com/search/label/eclipse">Nick</a>, <a href="http://mea-bloga.blogspot.com/">Chris</a>, and <a href="http://borisoneclipse.blogspot.com/">Boris </a>and to finally meet in person <a href="http://tom-eclipse-dev.blogspot.com/">Tom</a>, <a href="http://dev.eclipse.org/blogs/kevinmcguire">Kevin</a>, <a href="http://www.peterfriese.de/">Peter</a>, 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.<br /><br />A bit more personal, I like to think that the <a href="http://www.eclipsecon.org/2009/sessions?id=272">EMF tutorial</a> 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 ;-)<br /><br />I got some positive reviews for the <a href="http://www.eclipsecon.org/2009/sessions?id=565">modeled UI in e4</a> talk, which definitely doesn't seem to agree with the <a href="http://demo.birt-exchange.com/iportal/iv?connectionHandle=Q7whmBpUho%2Btg5MUYUgZxq1%2BrbtKHLkAq7RmnwSbegyRYEMWxKR8m0pEgUAaXCZHB8IjbbiKMgTuN20jQhwCeYK1hl9lo5oNYQrZtoylh4GYpuOq8tav1azRqIbjm2KEtge8WzpMA8ELhAa3jnpKVQkAWyReDcegY1w5eBs0j2cPwYCGunk7vDZvZZsbFGFIGmQMxVcJEAWJuDtctmcFW5Bem4qhXb%2BujApLPYBBGl2NfrUDopQBuUMkRgXFA6i2QQ%3D%3D&__svg=false&__masterpage=true&__locale=en_US&serverurl=http%3A%2F%2Fes2-N%3A8000&volume=BIRT%20Exchange&repositoryType=Enterprise&closex=true&iPortalID=KMUEHPUOUAUICBFSTQMSTJYJVWUTMNOVKVKM&__report=%2F%24%24%24Transient%2F642.RPTDOCUMENT&__report=/$$$Transient/642.RPTDOCUMENT&viewerId=js3">official numbers</a>. 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' <a href="http://eclipsecon.blogspot.com/2009/03/vote-with-your-feet.html">bucket</a>. Oh well... I am sure we'll do better the next time.<br /><br />Finally, a special thanks to <a href="http://inside-swt.blogspot.com/">Steve</a>: I was peacefully seated at the closing event when he handed me a winning deck for Thursday's <a href="http://www.eclipsecon.org/2009/poker">poker game</a>. My son loved the RC boat and will enjoy playing with it on summer time.<br /><br />Another finally... The EMF <a href="http://www.amazon.com/Eclipse-Modeling-Framework-2-0-2nd/dp/0321331885/ref=sr_1_2/105-2883004-8539639?ie=UTF8&s=books&qid=1188607318&sr=1-2">book</a> 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 ;-)Marcelo Paternostrohttp://www.blogger.com/profile/05767041268062110476noreply@blogger.com1tag:blogger.com,1999:blog-1094388580279212135.post-64291978327519764962008-09-27T18:08:00.022-04:002008-10-22T12:25:23.340-04:00I 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 ;-)<br /><br />I believe one of the reasons that I don't update this blog as often as I wanted to, besides being <a href="http://www-01.ibm.com/software/awdtools/appscan/build/">insanely</a> <a href="http://www.amazon.com/Eclipse-Modeling-Framework-2-0-2nd/dp/0321331885/ref=sr_1_2/105-2883004-8539639?ie=UTF8&s=books&qid=1188607318&sr=1-2">busy</a>, 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.<br /><br />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.<br /><br />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.<br /><br /><blockquote><pre>@Test<br />public void codeCoverageExample() throws Exception {<br /> runExampleAndCompareOutput(XYZ.class);<br />}</pre></blockquote><br />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 <a href="http://www.boomcounter.org/">black-turtle-neck-guy</a> says, "BOOM" : the annoying tests were out of my way ;-)<br /><br />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... <br /><br />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 ;-)Marcelo Paternostrohttp://www.blogger.com/profile/05767041268062110476noreply@blogger.com2tag:blogger.com,1999:blog-1094388580279212135.post-51807439577757616752008-06-18T18:37:00.007-04:002008-06-18T19:35:09.361-04:00"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.<br /><br />After four years dedicating myself exclusively to EMF, I am now working on the Rational AppScan Developer Edition team (our beta is available <a href="https://www14.software.ibm.com/iwm/web/cc/earlyprograms/rational/RASDE77OpenBeta/">here</a>). 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 ;-)<br /><br />The good news is that both <a href="http://ed-merks.blogspot.com/">Ed</a> 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 ;-)<br /><br />To me it will be a bliss to employ the technology that I help build. Although the EMF team has always eaten its own <s>dog food</s> 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.Marcelo Paternostrohttp://www.blogger.com/profile/05767041268062110476noreply@blogger.com0tag:blogger.com,1999:blog-1094388580279212135.post-4135628784238391272008-03-20T12:00:00.030-04:002008-03-20T12:26:04.975-04:00Platform scheme URIWow... 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 <a href="http://safari.informit.com/9780321331885">rough cut</a>), 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.<br /><br />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 <code>IFile</code> and <code>IWorkspace</code>. Sometimes it digresses to files available inside bundles and, rarely, it involves the "state location" of a bundle (see the <a href="http://help.eclipse.org/help32/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/runtime/Plugin.html#getStateLocation()">Plugin.getStateLocation() </a> javadoc for more details). Obviously you can use <code>IResource</code>s or <code>java.io.File</code> 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.<br /><br />There are a few ways to work with the "platform" scheme:<table border="1"><tr><td valign="top">platform:/resource</td><td>It 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.</td></tr><tr><td valign="top">platform:/plugin</td><td>It 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 <a href="http://divby0.blogspot.com/2007/06/managing-plugins-and-features-with-link.html">link folder</a> or in the default directory.<br /><br />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.</td></tr><tr><td valign="top">platform:/fragment</td><td>This 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.</td></tr><tr><td valign="top">platform:/meta</td><td>We 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.</td></tr><tr><td valign="top">platform:/config</td><td>The "config" segment causes the platform URI to refer to the configuration area of the running Eclipse (usually the <i>eclipse/configuration</i> directory). This can be useful to read the <i>config.ini</i> file, for example.</td></tr><tr><td valign="top">platform:/base</td><td>This always refers to the directory of the Eclipse being executed.<br /><br />It is interesting to note that, for example, <code>platform:/base/plugins/org.eclipse.emf/plugin.xml</code> and <code>platform:/plugin/org.eclipse.emf/plugin.xml</code> don't necessarily refer to the same resource. The former is a "pointer" to a <i>plugin.xml</i> file located in a directory <i>plugins/org.eclipse.emf</i> under the directory that Eclipse is installed. The latter points to the <i>plugin.xml</i> of the "org.eclipse.emf.ecore" bundle regardless of where it is installed and whether it is jarred or not.</td></tr></table><br />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 ;-)<br /><br />Since we all like actual code...<br /><blockquote><pre>IProject project = <br />ResourcesPlugin.getWorkspace().getRoot().getProject("myproject");<br />if (!project.exists())<br />{<br /> project.create(new NullProgressMonitor());<br />}<br /><br />System.out.println("\n==== platform:/resource ====");<br />{<br /> URI uri = URI.createPlatformResourceURI("myproject", true);<br /> System.out.println(uri);<br /> System.out.println(CommonPlugin.resolve(uri));<br /> <br /> uri = uri.appendSegments(new String[]{"folder", "file.txt"});<br /> System.out.println(uri);<br /> System.out.println(CommonPlugin.resolve(uri));<br />}<br /><br />System.out.println("\n==== platform:/plugin ====");<br />{<br /> // Just for fun, choose a bundle that is not in the default location<br /> URI uri = URI.createPlatformPluginURI("org.eclipse.emf.ecore", true);<br /> System.out.println(uri);<br /> System.out.println(CommonPlugin.resolve(uri));<br /> <br /> uri = uri.appendSegments(new String[]{"model", "Ecore.ecore"});<br /> System.out.println(uri);<br /> System.out.println(CommonPlugin.resolve(uri));<br /><br /> // Choose a bundle that is in the default location (<i><eclipse-dir>/plugins</i>)<br /> uri = URI.createPlatformPluginURI("org.eclipse.core.resources", true);<br /> System.out.println(uri);<br /> System.out.println(CommonPlugin.resolve(uri));<br /><br /> uri = uri.appendSegments(new String[]{"META-INF", "MANIFEST.MF"});<br /> System.out.println(uri);<br /> System.out.println(CommonPlugin.resolve(uri));<br />}<br /><br />System.out.println("\n==== platform:/fragment ====");<br />{<br /> URI uri = URI.createURI("platform:/fragment/org.eclipse.swt");<br /> System.out.println(uri);<br /> System.out.println(CommonPlugin.resolve(uri));<br /> <br /> uri = uri.appendSegments(new String[]{"META-INF", "MANIFEST.MF"});<br /> System.out.println(uri);<br /> System.out.println(CommonPlugin.resolve(uri));<br />} <br /><br />System.out.println("\n==== platform:/config ====");<br />{<br /> URI uri = URI.createURI("platform:/config/");<br /> System.out.println(uri);<br /> System.out.println(CommonPlugin.resolve(uri)); <br />} <br /><br />System.out.println("\n==== platform:/base ====");<br />{<br /> URI uri = URI.createURI("platform:/base/");<br /> System.out.println(uri);<br /> System.out.println(CommonPlugin.resolve(uri)); <br />}</pre></blockquote>The call to <code>CommonPlugin.resolve(URI)</code> returns a URI that uses a protocol which is native to the Java class library (file, jar, http, etc).<br /><br />I will leave it to you to run this code and see the results :-P Don't forget that it must be executed in an Eclipse shell. Probably the simplest way to do so is to paste these lines into a JUnit test located in a bundle and execute it as a "JUnit Plug-in Test".<br /><br />So what can we do with platform URIs? For one, read the contents of the resources pointed by them. We may also be able to write to such resources or even delete or create them. A tip for EMF 2.4 users: <code>URIConverter.INSTANCE</code> allows easy access to methods that are extremely handy when dealing with URIs (<code>createOutputStream(URI)</code>, <code>createInputStream(URI)</code>, <code>delete(URI)</code>, and <code>exists(URI)</code>).<br /><br />Personally I consider URIs a good fit for APIs that would normally use "plain" paths. Take as an example the <code>icon</code> attribute of the extension point below. Because its value is handled as a URI, we are allowed to refer to an image located in a different bundle.<br /><blockquote><pre><extension point="org.eclipse.ui.editorActions"><br /> <editorContribution ...><br /> <action <br /> icon="platform:/plugin/com.myplugin/icons/me.gif"<br /> ...<br /> /><br /> </editorContribution><br /></extension></pre></blockquote>BTW, if I were to implement the code to process such an extension point, I would probably do something like this:<br /><blockquote><pre>IConfigurationElement configurationElement = ...<br />URI iconURI = URI.createURI(configurationElement.getAttribute("icon"));<br />if (iconURI.isRelative())<br />{<br /> URI pluginURI = <br /> URI.createPlatformPluginURI(<br /> configurationElement.getContributor().getName() + "/", true);<br /> iconURI = iconURI.resolve(pluginURI);<br />}<br /><br />try<br />{<br /> ImageDescriptor imageDescriptor = <br /> ImageDescriptor.createFromURL(new URL(iconURI.toString()));<br /> descriptorImpl.setIcon(imageDescriptor.createImage());<br />}<br />catch (Exception e)<br />{<br /> e.printStackTrace();<br />}</pre></blockquote>This code assumes that when the value of the <code>icon</code> attribute is a relative URI (like <i>icon/me.gif</i> for example), the developer is indicating that the image is contained in the bundle that uses the extension point.<br /><br />For obvious reasons, I wrote these examples using EMF APIs, including our <a href="http://help.eclipse.org/help32/topic/org.eclipse.emf.doc/references/javadoc/org/eclipse/emf/common/util/URI.html">URI</a> class. It shouldn't be terribly difficult to rewrite the code in this post to use basic Eclipse and Java code (like, <code>java.net.URI</code>).Marcelo Paternostrohttp://www.blogger.com/profile/05767041268062110476noreply@blogger.com15tag:blogger.com,1999:blog-1094388580279212135.post-50997948729208481722007-08-31T12:43:00.000-04:002007-08-31T14:07:07.678-04:00Almost 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... <br /><br />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 <a hef="http://www.amazon.com/gp/product/customer-reviews/0131425420/sr=1-1/qid=1188580470/ref=cm_cr_dp_all_helpful/105-2883004-8539639?ie=UTF8&n=283155&qid=1188580470&sr=1-1#customerReviews">not so popular</a> "javadoc" chapter.<br /><br />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, ...Marcelo Paternostrohttp://www.blogger.com/profile/05767041268062110476noreply@blogger.com0tag:blogger.com,1999:blog-1094388580279212135.post-88023564430753890562007-07-31T16:06:00.002-04:002007-07-31T23:55:52.980-04:00No more NPE when generating modelsFor most users, <a href="http://www.eclipse.org/modeling/emf/downloads/?showAll=1&hlbuild=R200706262000&project=emf#R200706262000">EMF 2.3</a> 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 <a href="http://www.eclipse.org/modeling/emf/news/relnotes.php?project=emf&version=2.3.0">release notes</a>. 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 <b>try</b> to improve for this release ;-)<br /><br />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 <a href="http://www.eclipse.org/modeling/emf/newsgroup-mailing-list.php">newsgroup</a> and wait the excruciating 10 minutes delay that usually takes <a href="http://ed-merks.blogspot.com/">Ed</a> to answer.<br /><br />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 <i>.genmodel</i> file editor or, on the <i>.ecore</i> file editor, select a package and run the <code>Validation</code> 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.<br /><br />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.Marcelo Paternostrohttp://www.blogger.com/profile/05767041268062110476noreply@blogger.com1tag:blogger.com,1999:blog-1094388580279212135.post-50153713827535465942007-06-28T08:37:00.000-04:002007-06-29T12:06:04.689-04:00I 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 <a href="http://www.dilbert.com/">Dilbert</a> cartoon. Certainly Scott Adams' answer would be <a href="http://politicalhumor.about.com/library/jokes/bljokebushbrazilian.htm">brazilian</a> times funnier than mine, which is "crazy people implementing the cool things they want regardless of how beautiful the day is outside".<br /><br />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 <code>new FilteredTree(...).getViewer()</code> instead of <code>new TreeViewer(...)</code>. BTW, I would recommend reading the PatternFilter's Javadoc if you are considering doing the same in your code.<br /><br />Everything was going smooth up to the moment that I've opened a subclass of <code>org.eclipse.ui.dialogs.ElementTreeSelectionDialog</code>. 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: <code>ElementTreeSelectionDialog.doCreateTreeViewer(Composite, int)</code>. After blinking my eyes for a few seconds I realize that the method I need is already available in Eclipse 3.4. Amazing!<br /><br />Kudos to the UI team.Marcelo Paternostrohttp://www.blogger.com/profile/05767041268062110476noreply@blogger.com1tag:blogger.com,1999:blog-1094388580279212135.post-90469227751172768052007-06-26T22:14:00.000-04:002007-06-27T12:45:34.446-04:00EMF 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 ;-)<br /><br />So here we go...<br /><br />We've added a few new options to the EMF Resource in <a href="http://www.eclipse.org/modeling/emf/downloads/?project=">EMF 2.3</a> (the one available in <a href="http://www.eclipse.org/europa/">Europa</a>). One of them is <code>Resource.OPTION_SAVE_ONLY_IF_CHANGED</code>. 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.<br /><br />This snippet shows how to use this option:<br /><blockquote><pre>Map<Object, Object> saveOptions = new HashMap<Object, Object>();<br />saveOptions.put(<br /> Resource.OPTION_SAVE_ONLY_IF_CHANGED,<br /> Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);<br />resource.save(saveOptions);<br /></pre></blockquote><br />Using <code>OPTION_SAVE_ONLY_IF_CHANGED_FILE_BUFFER</code> instead of <code>OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER</code> 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.<br /><br />An experienced EMF user may be asking how this relates to the <code>Resource.setTrackingModification(boolean)</code> 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 <code>XMLResource.OPTION_LINE_WIDTH</code> option, for instance). The other two approaches do the exact opposite in these examples.Marcelo Paternostrohttp://www.blogger.com/profile/05767041268062110476noreply@blogger.com0tag:blogger.com,1999:blog-1094388580279212135.post-34729975607051453922007-06-08T01:09:00.000-04:002008-12-10T00:55:47.938-05:00From 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 <a href="http://www.eclipse.org/modeling/emf/">EMF</a>. 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<br /><blockquote><pre>for (Iterator i = Collections.singleton(new Integer(1)).iterator(); i.hasNext();)<br />{<br /> Integer integer = (Integer)i.next();<br /> System.out.println(integer);<br />}</pre></blockquote><br />should look like this after the modifications<br /><blockquote><pre>for (Integer integer : Collections.singleton(new Integer(1)))<br />{<br /> System.out.println(integer);<br />}</pre></blockquote><br />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 <code>Object object :</code> instead of <code>Integer integer :</code> for the example above.<br /><br />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):<br /><br /><div style="text-align: center;"><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEretuJTig1Fg5XBcyMFn14tTrpLrbo5LqLJeYGoi5L6g7-KAliCJc_cCNpZDFbB1sA7KormrHxXLloZHvuxoqXfBz-0r8XJZDk-tiliafMPBJ839sW2uFk7VK9CYwjEYC9MPiukcBecVw/s1600-h/Find-Replace.png"><img style="margin: 0pt 10px 10px 0pt; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEretuJTig1Fg5XBcyMFn14tTrpLrbo5LqLJeYGoi5L6g7-KAliCJc_cCNpZDFbB1sA7KormrHxXLloZHvuxoqXfBz-0r8XJZDk-tiliafMPBJ839sW2uFk7VK9CYwjEYC9MPiukcBecVw/s320/Find-Replace.png" alt="" id="BLOGGER_PHOTO_ID_5073559582647518418" border="0" /></a><br /></div><br />Here's a clipboard friendly version:<br /><blockquote>Find:<br /><pre>(for\s*\(\s*)Iterator\s*\w*\s*=(.*)\.iterator\(\).*;\s*(\)\s*\{\s*)(.*)\s*=.*next\(\);\s*</pre><br />Replace with:<br /><pre>$1$4:$2$3</pre></blockquote>Marcelo Paternostrohttp://www.blogger.com/profile/05767041268062110476noreply@blogger.com5tag:blogger.com,1999:blog-1094388580279212135.post-58280430512352235912007-06-04T10:35:00.000-04:002007-06-05T10:51:15.206-04:00I can't see the code I blog!Today I was proudly showing my blog to Dave, a good friend from work. "Proudly" would be the perfect word if it also meant "embarrassed". While I consider myself an illiterate in multiple languages (after 7 years in Canada I haven't learned English yet and my Portuguese is starting to fade away), Dave is my "English hero". Not only he writes really well but also knows all the grammar rules that would explain "why one should use a comma here" for example. A typical case of knowing what to do and how to do it. Anyways, I am digressing...<br /><br />When I was showing the blog to Dave, he pointed out that the chunks of code I wrote were not been properly displayed on his Windows box. After some digging, we found out that the culprit was the "fixed" font on my CSS. After changing it from<br /><blockquote><pre>font-family: fixed, courier, courier new, times, times new, times new roman;</pre></blockquote><br />to<br /><blockquote><pre>font-family: courier new, courier, fixed, times, times new, times new roman;</pre></blockquote><br />everything worked just fine.<br /><br />Perhaps I should show this to <a href="http://divby0.blogspot.com/">Nick</a>, another good friend from work, from whom I've stolen... err... leveraged the CSS customizations.Marcelo Paternostrohttp://www.blogger.com/profile/05767041268062110476noreply@blogger.com1tag:blogger.com,1999:blog-1094388580279212135.post-88945741944775370392007-06-01T23:37:00.000-04:002007-09-09T18:40:31.432-04:00EMF? O que é EMF?Geralmente quando leio algo sobre o <a href="http://www.eclipse.org/modeling/emf/">EMF</a> em Português, acabo aprendendo alguma coisa sobre MyEclipse ou <a href="http://www.eclipse.org/vep/">VE</a>. Pelo visto o pessoal ainda não descobriu o poder deste componente, tratando-o apenas como mais um incômodo detalhe de instalação.<br /><br />O EMF, do qual sou desenvolvedor, pode simplificar drasticamente o desenvolvimento de aplicações Java (a serem rodadas no Eclipse ou não). A partir de uma especificação de um modelo (em XML Schema, por exemplo), com apenas alguns cliques, é possível gerar um editor no Eclipse capaz de criar e manipular instâncias deste modelo. Por trás das câmeras, o editor utiliza outro código Java, também gerado pelo EMF, que implementa as classes definidas no modelo. Em outras palavras, se o modelo diz que uma Biblioteca tem Livros, o EMF vai gerar algo parecido com<br /><br /><blockquote><pre>public class Biblioteca<br />{<br /> List<Livro> getLivros();<br />}</pre></blockquote><br />Este código é completamente independente do Eclipse, podendo rodar em qualquer ambiente Java. A propósito, Java 5 é opcional.<br /><br />O EMF pode fazer <span style="font-weight: bold;">muito</span> mais que simplesmente gerar código para classes. Espero ter tempo e, porque não, incentivos em forma de perguntas e encorajamentos, para escrever, em Portuga, algumas dicas.Marcelo Paternostrohttp://www.blogger.com/profile/05767041268062110476noreply@blogger.com0tag:blogger.com,1999:blog-1094388580279212135.post-88323070763407546032007-06-01T22:43:00.000-04:002007-06-27T11:09:47.123-04:00I'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.<br /><br />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).<br /><br />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 (<a href="http://www.eclipse.org/modeling/emf/">EMF</a>).<br /><br />Modeling and objects to the bone!Marcelo Paternostrohttp://www.blogger.com/profile/05767041268062110476noreply@blogger.com0tag:blogger.com,1999:blog-1094388580279212135.post-3422426057552337432007-06-01T21:58:00.000-04:002007-06-05T10:52:51.736-04:00What do I do with my passwords?Have you noticed the incredible number of services, emails, accounts, logins and identities we have to manage on a daily basis? I am sure you already have a technique to handle your ids and passwords. The one I chose is... keep all my information in a text file.<br /><br />Of course it is not that simple ;-)<br /><br />I do have a text file with all my ids and passwords though. I write it in a very human legible format (== no xml). You would read something like this if you got your hands on it<br /><br /><blockquote><pre>www.pizzapizza.com<br />marcelop/mypass<br />marcelop@the.email.I.used.here.com</pre></blockquote><br /><br />This file is stored on my server, where I make all the changes, and duplicated on the machines I use. Given the importance of the data (to me at least), I decided that it would be wise to encrypt it. Enters <a href="http://ccrypt.sourceforge.net/">ccrypt</a>. This package is available on both Linux and Windows (through <a href="http://www.cygwin.com/">Cygwin</a>), and provides a command line application (ccrypt) to encrypt text files and another (ccdecrypt) to do the opposite operation. It also includes 'ccat' that displays the content of the file after decrypting it in memory.<br /><br />So how do I put everything together? When I need to add a new entry to the file, I ssh to my server and run <code>cad</code>, defined this way:<br /><br /><blockquote><pre>alias cad='ccdecrypt ~/personal/ids.txt.cpt &&<br /> vi ~/personal/ids.txt &&<br /> ccrypt ~/personal/ids.txt'</pre></blockquote><br /><br />This command (1) decrypts the file 'ids.txt.cpt', (2) opens the plain text file using vi, and, after I am done editing it, (3) encrypts the 'ids.txt' file.<br /><br />After editing the ids file, I return to the machine I am working on (this has started with an ssh, remember?) and run the <code>psync</code> command defined by the following alias<br /><br /><blockquote><pre>alias psync='scp -p lh:/home/marcelop/personal/ids* ~/personal'</pre></blockquote><br /><br />which copies the file located on my server (the alias stands for "personal sync" and actually copies other files that I only edit on the server). After that, whenever I want to check an specific information, I run this alias on the local machine<br /><br /><blockquote><pre>alias cad='ccat ~/personal/ids.txt.cpt | grep -i -B 2 -A 5 '</pre></blockquote><br /><br />So something like <code>cad pizza</code> would display 2 lines above the "pizzapizza" entry and 5 below. Adding this to the .bashrc<br /><br /><blockquote><pre>export GREP_OPTIONS='--color=auto'</pre></blockquote><br /><br />makes it even better, since the word "pizza" would appear in red.<br /><br />There you are. Seems like a lot of work, but it is actually quite simple. After using this technique for 2 years, it feels absolutely natural.<br /><br />PS: 'cad' stands for "cadeado" (locker in Portuguese).Marcelo Paternostrohttp://www.blogger.com/profile/05767041268062110476noreply@blogger.com0tag:blogger.com,1999:blog-1094388580279212135.post-76011268796538701082007-06-01T21:39:00.001-04:002007-06-05T10:53:55.423-04:00Ubuntu!!!!I don't really hate Windows. Although it is fun to trash it from time to time, it does have its strengths. That said, long life to the Penguins! After using <a href="http://www.debian.org/">Debian</a> for a while, <a href="http://www.ubuntu.com/">Ubuntu</a> has made his way into my Desktop and Thinkpad. The former runs on Dapper LTS (I am planning to upgrade it to Feisty in July) and the latter boots Edgy (and, occasionally, Windows XP).<br /><br />Why Edgy on the Thinkpad? Feisty just doesn't do it for the lappy. Several annoying problems, going from issues connecting the wireless adapter to 'division by 0' exceptions thrown by Skype and VLC made me choose an earlier version of the distribution. Oh well... In October I can give G* (whatever 7.10 is named) a try.<br /><br />PS: In my case, the 'division by 0' was happening because the geometry of the screen was not set. Running <code>xrandr</code> did the trick for me.Marcelo Paternostrohttp://www.blogger.com/profile/05767041268062110476noreply@blogger.com0