Flex, Spring and BlazeDS: the full stack! (Part 2)

[UPDATE 2] If you are still having version issues with the sample application featured in this article, you can get a fully upgraded version here

[UPDATE] This article series has been reedited on the Adobe Developer Connection. For more information, see this post.

In the previous article of this series, I laid the ground for what will be a step-by-step tutorial about creating a Flex/BlazeDS/Spring/Hibernate project. In this article, I will go into more detail about the creation of the Flex UI for our Todo List application.
(more…)

Flex, Spring and BlazeDS: the full stack! (Part 1)

[UPDATE 2] If you are still having version issues with the sample application featured in this article, you can get a fully upgraded version here

[UPDATE] This article series has been reedited on the Adobe Developer Connection. For more information, see this post.

In this article series, I’ll try to give you a step-by-step process to create an application with Flex/BlazeDS/Spring/Hibernate/MySQL architecture, all of that built with Maven. I’ve been looking for such a tutorial for a long time, but you know what Gandhi said about the change you wish to see in the world, right? So I finally put all the parts together, and with a little help from a Brazilian friend, tadaaaa! Here it comes!

But before we dive in to the hard stuff, just a few words of caution:

  1. The project that we are going to build in this tutorial is by no means perfect, especially in terms of Maven configuration. So if you have suggestions to improve it, they’ll be warmly welcome.
  2. One of the main ingredients of this project, one without which nothing would have been possible, is the flex-compiler-mojo from Velo. There are other Flex building Maven plugins out there, but at the time of this writing, none of them offers enough configuration options to build this project. On the other hand, Velo’s plugin is still in alpha, so… Anyway, if like me you are convinced that Adobe’s official Maven support is necessary, feel free to vote for this issue.

Enough blah-blah, let’s move on to the real thing. Ready to get nasty?
(more…)

My thoughts about OSGi on JavaWorld

A few weeks ago, I’ve been interviewed by Andrew Glover for JavaWorld’s Java Technology Insider podcast and it’s been published today. So without further ado, feel free to check out our talk here.

Now if you want to read it rather than listen to it, I’ve prepared a transcript for you guys. I’ve added a few links inside the transcript for the references I mention.

(more…)

WaaP? SaaS!

What a cryptic title isn’t it? How about web as a platform and software as a service? Are you still wondering what it means. Well I just have a couple of good examples for you.

Did you imagine that a creative task like image editing would one day possible inside your browser?

What Does it Take to be a good RIA Platform?

Yesterday, I had a very interesting blog debate with a guy named Martin Beeby. He was arguing that Silverlight would eventually crush Flex because Adobe is building its community on Flash developers, who are in fact designers. Of course I couldn’t help demonstrating to him that he was wrong, because Adobe is obviously not trying to transform Flash designers into Flex developers, and is actually trying to add developers to its already existing designer community. But ultimately he made an interesting statement: according to him, RIA’s require both developers and designers, and both Microsoft and Adobe are trying to convince the ones they don’t already have in their community.

I had never thought of it that way. As a matter of fact, if you have a look at most Flex apps available out there, rare are those who use the default theme provided by the Flex SDK. In fact, Flex apps are so easy to customize using themes and stylesheets, that it’s perfectly understandable. Adobe is even pushing us in that direction with tools like Thermo or Flash Component Kit.

Adobe Thermo

But do we really need that level of customization? In fact, in enterprise applications, this themeing mania can even do more harm than good, unless you use a standard WindowsXP-like theme, because they don’t want fancy stuff, they just want transparent software.

He used another argument in favor of Silverlight, the fact that it’s generating more buzz lately. With showcase applications like Beijing Olympic games website, or the new AOL Mail interface, Silverlight is definitely trying to draw the attention on itself. Is it working? Hard to say.

But all of this debate made me think about what makes a good RIA platform. Here is my list:

  • the runtime has to be as widespread and portable as possible: on that point Flex is clearly ahead with its 95%-ish penetration rate, but the Flash runtime still suffers from a bad reputation in IT departments. On the other hand, Silverlight is still far behind but it has a tremendous advantage: Windows Update.
  • behind the fancy stuff, the code has to be simple, clean and state-of-the-art: that’s one of the main reasons why I love Flex, the ActionScript/MXML combination is just perfect, and it doesn’t even require any framework. I don’t know anything about Silverlight code, so I will probably have a look at some tutorials before commenting on that.
  • it has to be supported by a wide variety of development tools: Flex Builder is great but it’s still quite expensive, especially when you’re not using Eclipse at all and it forces you to run two development environments side-by-side. Fortunately, IntelliJ Idea has added support for Flex 3 and it’s becoming great. The last thing it misses is a visual designer. But given their experience with their Swing designer, I’m certain they are working on something (I hope so!). And all of that is possible thanks to the openness of the platform. On the other side, Silverlight is supported mainly by Visual Studio, and I haven’t heard of any openness effort that would allow other .Net development tools to support it.
  • RIA is all about the presentation layer, so it has to be connected to some backend to be useful, and the more backends it supports the better: Flex is really ahead on that one, since it can be plugged on Coldfusion, J2EE, .Net, PHP, Python, Ruby and virtually any platform via its webservice connectivity. But what makes it really powerful now is the extension of Java support thanks to BlazeDS. And apparently, Silverlight doesn’t have an equivalent communication protocol.
  • it has to be deployable on any platform: Flex just produces plain SWF Flash applications, so it doesn’t require any server-side technology. A plain Apache httpd server is enough. I don’t know what are the requirements of Silverlight on that matter.

Now what do YOU think? Do you see anything to be added to the above list? What are your criteria? Have you already had to make a choice and justify it?

Goal-Driven Development

It’s always amazing to see how people find it hard to compromise, to nuance their opinions about things. And I’m probably the first one finding it hard. But when it comes to software practices, boy it’s annoying.

I was talking to a colleague of mine the other day, we were talking about unit testing and other best practices, and I boldly and shamelessly said to him: “I haven’t written any unit test on this project.” He stared at me with a bit of surprise, then with a bit of disappointment and finally with a bit of something like… disgust!

“What!? No tests, but why? How can you pretend to be a software architect if you don’t practice systematic unit testing?! Oh my god!…”

My first reaction was a furious urge to hit him in the face. But then I remembered myself a few years back, and I did nothing but leave him in his panic state and disappointment.

When I started working as a consultant, I had already written a few applications in engineering school, but strangely enough they didn’t really talked to us about software quality, agile methodologies and other modern best practices. We did formal programming, Prolog, we reprogrammed a memory management unit and wrote a compiler for a subset of the Java language, but nothing useful ;o).So when I discovered that some people were actually doing things in a rational way, to write better software, I was at the same time impressed and overwhelmed by all of that. Design patterns, continuous integration, test-driven development… I had never seen those in the real world, but I read a lot of books and websites and it seemed so nice that I came to think that it was the only way. And of course I was wrong.Fortunately, I started working on real-world projects, dealing with all sorts of external constraints. And no matter how hard I tried to impose “my” great software best practices, everybody looked at me like an alien because they just didn’t understand why I was talking about all this stuff. So when I was fed up with complaining about no one understanding what should be done, I realized that they were at least right to wonder. Why are things like TDD, CI or Design Patterns so important?

When you read so many articles explaining to you how to write unit tests, they all seem to assume that unit-testing is good in itself, as if it was some kind of axiom. But the truth is that no matter how good they are, writing them and maintaining them is a real pain, right? Lesson learned: when something is painful but good for you, there’s gotta be a better way. But a better way to what?

Because for me that’s the real problem: losing sight of the objective. Unit-testing and TDD are not good in themselves, they are just one best practice which allows you to improve the overall quality and robustness of your code. Why so? Because when you write your tests before the corresponding functional code, you considerably reduce the probability of a bug in the functional code. And robustness comes from the fact that whenever the implementation of a given functionality is modified over time, unit tests are there to ensure that the overall result will remain the same. Fine! But how about a better way?

First, let’s talk about reducing the probability of bugs. The main problem with code is that it’s written by us, human beings. And like it or not, we are faillible, we make mistakes, and the more we think we don’t, the more we actually do. Now rather than testing everything that we write, isn’t there a way to reduce the amount of code that we have to write? I can tell you that: there is a way!

I already see my colleague smiling if he reads this, because I’m so obsessive about this “way” that it becomes ridiculous. Take care, here comes the dirty words: code generation. Of course I’m not talking about the kind of code generation that just displaces the problem elsewhere, that is in diagrams that are the ont-to-one mapping of your code. I’m talking of a higher level of code generation, I’m talking of Model-Driven Architecture.

I know that many programmers don’t like it, have read many articles about and introductions to MDA without ever going further, mostly because programmers like to… program, not draw. And I can understand that. And if you’re in that situation, then you’re stuck with test-driven development… or any other “way” you can find. But if you like to have a better view of the big picture, if you want to accelerate your development and increase the robustness and quality of your code, then have a look at this (my favourite), this and this. You might be surprised.

Will it completely replace unit tests? I don’t think so, but it can create a situation in which you have so dramatically reduced the amount of code to test, that it can be interesting to wonder whether it’s still worth the effort.

My main point is, software best practices are nothing without the goal they allow you to reach, and forgetting that is the best way to stop looking for better ways, to stop innovation and progress.

RIA on Your Phone?

I love Apple. I confess I’m a pure fanboy, writing this post on a Macbook Pro I’m very proud of, and I really admire what Steve Jobs has managed to do with this company in just more than 10 years since he returned. But yesterday he did another of these annoying things I really hate: he denigrated a competitor. I mean, when you have great products like Apple does, you don’t need to do that sort of things, and if you do, it obviously means that you are afraid of them.

flexiphone.pngSo when Steve Jobs says that “Flash is not suited for the iPhone“, I don’t hear “Flash will never be available on the iPhone” but “Flash will eventually adapt to the iPhone and when this day comes, we’ll have to deal with it.” The truth is that Adobe has been doing huge things with Flash lately, thanks to Flex. And I’m sure Steve is aware of that. And I see absolutely no coincidence in him spreading that kind of FUD on the same day he’s announcing the iPhone SDK.

For months, Apple has been telling us that we didn’t need any SDK for the iPhone, because we could just write standard AJAX web applications, which is nothing more than a transitional form of rich internet application. Now that the SDK is out (and it really amazes me by the way, but that’s another topic), the web application way of doing things looks really poor in comparison, both more complex to use and less integrated than its heavyweight client alternative. But what if Adobe comes up with a Flash runtime for the iPhone supporting Flash 9 and Tamarin? Then we will have Flex applications on the iPhone, in other words easy-to-develop apps, with no need to go through the App Store. And if Adobe does things right and uses the full power of the iPhone APIs, maybe we could have some special capabilities to integrate multi-touch and other advanced features into our rich mobile applications.

Wouldn’t it be great?!

Now the question is, if Adobe comes with such an adapted Flash support, will Apple accept this alternative and pre-install it on all new iPhones?

I really hope so… But what do you think?

The Testing Dogma

When I was in college, we had a very talented physics professor coming directly from Scotland. And as I was in a French engineering school, I was more used to the French way of teaching science, with a lot of theories, demonstrations and proofs. So when I first saw this guy with all his experiments and observations, I thought the man was crazy but in the end, a fact was a fact, and I didn’t really care about why a specific equation applied. I just needed to be convinced it was true… until someone proves us wrong. That’s what science is all about.

Yet, some French scientists tend to be distrustful with the whole empirical stuff, probably because they can’t help thinking that it’s not because you observe something a 999 times that it’s going to repeat itself  a thousandth. So the best alternative we have is to prove it by theory, using mathematics and a lot of tools like theorems, matrices, integrals, etc., even though it’s far more difficult. And once it’s proven with theory, we can more or less take it for granted (provided our reasoning is valid).

Now what if I want to assert something about a piece of software? I can either create an experiment to show that it repeats itself: that’s a unit test! Or we can prove it theoretically using mathematics… Yes, there are formal languages that allow you to prove your programs. They’re very complex to use but hey, reliability has a price!

Fortunately for us, the metaphor stops where the specificity of our case begins, because with software, we have a third option. I won’t say the dirty word right now because I know you’ll run away. Let’s just consider that there are basically three types of testable code:

  • code that is very simple to write but you’re testing it because you want to make sure that no one can break it with a wrong copy-paste or something like that
  • business code which is a bit more complex, for which you have to write equally complex test code, with the risk of having correct code tested by wrong test
  • all the rest, which in my experience is not as much as we think usually.

Based on my experience, I would tend to do the following:

  • I write regular unit tests for ALL the rest.
  • I don’t test complex business code, I do code review on it.
  • For simple code, I shouldn’t even have to write it in the first place. If it’s so simple, then it can certainly be generated automatically by a generator I trust (that’s it! I said it!)

What’s your position really? Set aside the “testing-is-good vs. not-testing-is-bad” dichotomy, what would be your testing strategy? Do you use code generators to avoid testing boilerplate code?

JBoss is working on OSGi too

home_callout_jbossosgi.gifI wanted to download the latest version of JBoss AS to deploy it to a new server, and while I was wandering round their site to see what is going on, I found an interview of Ales Justing by Mark Newton about the work they’re doing with OSGi.

Apparently they are not waiting for it to happen. They’re really taking part in it, which is refreshing because ever since Redhat acquired them, I’ve always been afraid of the possibility that they could rest on their achievements and have trouble keeping up with innovation. Obviously I was wrong and since they even have some people inside the Enterprise Expert Group, we can expect some pretty good integration of OSGi into future releases of JBoss.

They are even going as far as reengineering a key part of their architecture, which is the microcontainer, to integrate OSGi. That’s really an excellent thing because I’ve always found that JMX is really a pain to manage. According to the interview, they are totally changing their core classloader:

We could probably use the classloading features of existing OSGi frameworks but it would again mean bending around things to make them work. As we wanted to have a bullet proof implementation, where all the nasty details were hidden away under private/protected modifiers, it was important that we could tightly control access through policies and delegation. From this perspective it made more sense to implement our own classloading layer.

Concerning integration with Spring, apparently they are still taking their distances. I guess it has something to do with the fact they Spring/Hibernate competes with EJBs and has thus encouraged many developers to choose a simple Tomcat server instead of a full-blown JBoss for their deployment. But as long as I can freely deploy my Spring/Hibernate on JBoss and still benefit from features like SOAP, JNDI, JMS and so on, that’s fine with me.

So that’s one other major actor of the enterprise application server market who is moving towards OSGi. Did I already say that it’s going to be big? And OSGi DevCon is certainly going to be very important this year.

The Flex Office Suite is (almost) Complete

Today, I’ve discovered yet another great Flex app that completes my online Flex Office basic suite. It’s called BList and once again, the ease of use of Flex has made ot possible for its creators to be really creative about the way to create spreadsheets. And what I really love is that you are not lost with their new way, since you’re litterally taken by the hand and everything is explained.

So now we have:

What else do we need for it to be really complete:

  • A mail application, like GMail or LaszloMail (that is now GoWebtop) but with a more creative approach of course
  • A good calendar app, something with simple tools to synchronize meetings ala Doodle for example, possibly synchronized with the mail system for invitation
  • And obviously there is a lot of creativity needed in the personal database area

Now imagine if Adobe bought all of the existing startups mentioned above (they have already bought Buzzword) and created the missing tools to build up a great Flex online Office suite, possibly with AIR spin-offs for each application…

What do you think? Do you know of any other Flex app out there that could be integrated in this online Office suite? Would you be interested in such an integrated toolset? Would you or your company be ready to pay a subscription for it?

[edit]
Mike Potter just pointed me to another incredible example of creativity allowed by simple technology. It’s a personal organization tool with a calendar, todo-lists and notepads like I’ve never seen before. I’ve added it to the list above. It misses some meeting synchronization features but it’s really excellent.
[/edit]