Top 10 Reasons to Prefer JSF over Struts

David Geary (author of Core JavaServer Faces) posted a top-10 list of reasons why he thinks you should choose JSF in preference to its arch-rival Struts.

That is (because we have to be precise about these things), a web framework based on the official JSF specification versus the open-source web framework Struts.

It’s a good summary, and highlights many of the problems which Struts users are obliged to face every day – although the semi-irate messages following the article also highlight one or two of the related problems which JSF users must also face (XML Hell springs to mind).

Of course, there’s also the school of thought which says that web frameworks are actually kind of evil, because they define a rigid architecture for you, and force you into lots of pre-ordained design decisions which may or may not be appropriate for your project. Coupled with this, there’s the risk that developers who get too “into” their chosen framework get too immersed in framework issues, and forget to think about the business. Perhaps it’s really the religious devotion to [[your framework of choice]] which is kind of evil, rather than the frameworks themselves.

Frameworks, and web frameworks in particular, seem obsessed with moving as much as possible into XML, even stuff which arguably belongs in code (e.g. business logic). Meanwhile, when Java annotations become more common, I’m sure we’ll also see config things which really should belong in the XML (JDBC URLs, that sort of thing) make their way merrily into our Java files. It’s all quite topsy-turvy – but that’s a story for another day...

An alternative to adopting an “architecture-busting” holistic framework is to define the architecture yourself (based on best practices, natch) and instead pick and choose individual libraries and toolkits to perform specific functions, or groups of related functions. For example, the open-source Swinglets toolkit fits into your architecture without requiring you to structure your web-app in a particular way, or to get too carried away with "latest-greatest" design fashions.

There are times when choosing to use a web framework such as JSF or Spring Web MVC (coupled with the emerging Spring Web Flow) is the right decision. But there are also times when it’s better not to bow down to the Framework Gods, and instead indulge in a little bit of “DIY thinking”.

About the Author

Matt Stephens is a senior architect, programmer and project leader based in Central London. He co-wrote Agile Development with ICONIX Process, Extreme Programming Refactored, and Use Case Driven Object Modeling with UML - Theory and Practice.