10.30.2008

Is JSF Fixable?

Subbu says that JSF is Not Fixable. His he right or his he wrong? That is the question!

I've been wanting to write about JSF for a while now. I was an early adopter and big proponent of JSF when it first appear at the surface of Java land. Since then, I've worked on many projects that used this framework and slowly but surely, my opinion changed about this framework.

In Subbu opinion, JSF is not fixable because it was not designed with web architecture in mind. The framework is not RESTful and requires POST for everything. JSP proponent argue that RESTful is coming to JSF and it is even already supported right now when you use JBoss Seam.

It's true, that JSF is getting better. Facelets will become part of JSF (it should have been there from day though - why make a brand new framework and use broken things like JSPs). JSF 2.0 will make some space for GETs and JBoss Seam fixes a lot of other issues with JSF.

However, if JSF is not Fixable, it is not solely because it is not RESTful. JSF is broken at many places.

The JSF request processing life-cycle is one of the worst thing about JSF. There is so many steps in the life-cycle, different ways to exit the normal processing and this gives something many entry points for custom components (one for each steps in the life-cycle). Things can go wrong at many places without even touching your application code.

Closely related to the request processing life-cycle, is the component model. In JSF, components are a kind of black box. But when you think that black box should be mostly independent on the framework (beside the connecting part with the framework), there is so many implementation leak in JSF, that your component must be ported to every JSF implementation. I say ported and not tested... Because the order in which the component tree is processed can make you component fail. You have to make so many assumption based on the JSF implementation (things that are not present in the specification) that you actually need to choose your JSF implementation carefully and will never be guaranteed that your component will survive even minor updates in the JSF implementation.

Want to add to functionality to an existing component? There is no easy way to do that. The best way, is to take the source code (if available) for the component and refactor it with some new name and then hack you way through it. And when I say hack, I mean it in a bad way! I've never saw a component source code that was easily readable and understandable. Large component sets like ADF Faces are notably ugly. Even the Swing component model (which is quite complex) is super simple compared to JSF component model.

It looks like in JSF, the worst thing about leaking abstractions made it into the framework and the good thing about encapsulation where left out.

And before I get flamed that you will be able, with JSF 2.0 - which is still in draft, to create composite components soon... I have to respond that soon is not now.

One of a good indication that JSF is broken beyond fixable, is that you cannot do simple thing simply. Want to create a new component, then you have something like 3 files to edit. Want to create a new converter, again, three files needs to be edited. I know that good thing came in sets of three, but this is not the kind of good I want.

Another good indication that JSF is broken beyond fixable, is when thing go wrong. Good luck finding you problem... Facelets help you a bit by giving you a more precise location of the issue. But it does not always work. When you look at stack trace, you have to scroll hundreds of line before you see the line from you application. But what the hell do you do when you don't even have any of you application code in the stacktrace? Why on earth, you are have a stacktrace that is 30-40 level deep before even reaching an action method? Just to process a fringing POST.

In JSF, the framework is everywhere except where you need it.

Yes, there is some good things about JSF, I like the expression language (even is it is a bit inconsistent and not powerful enough to my taste). But the bad things are so deeply rooted. If you are just a user of the framework and that you are writing really simple applications, then it does look like JSF is great, but whenever you start digging a bit and adding a bit of complexity (Ajax anyone? Without another component set that takes a few MB?), the framework start eating up your nerves.

So would I ever recommend JSF again? Maybe maybe not, in the Java world, there is so many framework to choose from, that your cannot recommend one with the certainty that it will still be around one or two years from now. The only sure thing, is that JSF will be there because it is the standard... And this is very sad!

8 comments:

Deli said...

Yes, and every one of your points will be addressed by JSF 2.0. Just look at the JSR 314 page at JCP:

Component aggregation. Allow development of custom component with little or no Java coding. [A] Perhaps consider a standard set of aggregations.

Eliminate the need to author a JSP tag handler when writing JSF components.

Leverage annotations to declare JSF artifacts (components, managed beans, navigation rules, etc) to the runtime.


Re-do UIComponent state saving with a view towards making stateless components the default.

Improve the UIComponent specification to allow an increase in the interoperability of UIComponent libraries from arbitrary vendors.

Vastly improve the developer experience with regard to error messages that happen during iterative development, and even during deployment of the application. For example the EG will consider options including, allowing the developer to tell the runtime what stage of development the web application is in, and take action accordingly: Development, Test, Deployment. Line precise error reporting. Pluggable Exception Handling.

Provide default exception handling mechanisms. For example, all runtime errors get forwarded to an error page.

... They have been listening and are addressing every pain point people have brought up. So yes, JSF can be fixed. If they are willing to rip its heart out to re-do components, templating, statelessness, etc. then why wouldn't they fix everything else?

Subbu Allamaraju said...

Your last statement "The only sure thing, is that JSF will be there because it is the standard... And this is very sad!" is simply hilarious. That summed up the sentiment well well.

Deli said...

The only people who think JSF is frozen in time are those ignorant enough to blog about the very issues being addressed by JSF 2.0 and use them as examples of why JSF can't be fixed. There isn't one issue you or Subbu brought up that isn't being fully addressed. How can you guys say such things?

Emmanuel Pirsch said...

JSF 2.0 addresses only some of the issues outlined in my post. It will not make developing component much easier. Having one less file to edit is not enough. The component model is broken. Leaking abstractions are not solved in JSF 2.0. Besides adding some support for GET, JSF 2.0 is basically JSF 1.0 with Facelets.

If fixing JSF means "to rip its heart" as you said, then it is broken beyond fixable. Starting over would be much simpler and much more efficient.

It would've taken less time to write a completely new framework than the time it takes the JCP to come up with a final release of JSF 2.0.

And by the way, you don't have to call people ignorant to make a point (my post criticize technology not people)! I based my blog post on my many years of experience with JSF. While I was exited at first with JSF, the bloat and poor designed choices that it is made of made me change my mind.

JSF 2.0 is not here yet... And there are plenty of other frameworks that have none of the shortcomings of JSF, that are less bloated and much more fun to use (a bit too many, but that's another story).

Please open your mind to criticisms and try out some other stuff out there (and it does not have to be Java stuff). And please stop calling people names.

Subbu Allamaraju said...
This comment has been removed by the author.
Subbu Allamaraju said...

Deli:

Regarding your comment on "How can you guys say such things?", here is my response. AFAIR, it has been four years since JSF 1.0 was released. It took this long to recognize and attempt to the core architectural issues, and a lot of kludgy stuff has been built around JSF in these four years. This is a costly mess. The issues I pointed out are so fundamental to the web that these should have been addressed in the 1.0 release.

I hope they get it right this time.

Anonymous said...

Please guys, you experts should join the JSR and fix things before JSF 2.0 gets out.

Anonymous said...

"Is JSF Fixable?" - by no means

AdSense Links