Most interesting links of June

Recommanded Readings


Continue reading →

Validating JSF EL Expressions in JSF Pages with static-jsfexpression-validator

Update: Version 1.0 was released in March 2012 Update: Version 0.9.9 with finished basic support for Facelets (autodetection of annotated beans, handling of ui:repeat) is available Update: Version 0.9.7 with experimental Facelets support and a fix of method binding validation released in Nov. (Not mentioning 0.9.5 and .6.) Always check the latest version available! The text below would need to be updated for the new API, which will be done by the end of 2011. Update: Version 0.9.3 with new group/artifactId released on 7/25 including native support for JSF 1.2 (reflected below in the pom snippet). Update: Version 0.9.4 with function tolerance for JSF 1.2 released on 7/28 (it doesn't check functions are OK but checks their parameters etc.)

static-jsfexpression-validator is utility for verifying that EL expressions in JSF pages, such as #{bean.property}, are correct, that means that they don't reference undefined managed beans and nonexistent getters or action methods. The purpose is to make JSF-based web applications safer to refactor as the change of a method name will lead to the detection of an invalid expression without need for extensive manual UI tests. It can be run statically, for example from a test. Currently it builds on the JSF implementation v. 1.1 but can be in few hours (or days) modified to support newer version of JSF. How does it work?


Continue reading →

How to Fix Empty "Show all bookmarks" in Firefox 4

Since recently I was unable to edit my bookmarks because Bookmarks -> Show all bookmarks displayed en empty list of bookmarks, though the bookmarks were under the bookmarks menu, B. toolbar etc. The Bookmarks side panel was also empty though.

The solution was to create a backup of my bookmarks (in the json format), stop FF, delete places.sqlite from my profile, start FF and restore bookmarks from the backup.


Continue reading →

Hacking Jasper to Get Object Model of a JSP Page

To perform some checks and statistical analysis on my JSPs I needed a DOM-like, hierarchical model of elements contained in them. But parsing JSP pages isn't trivial and is best left to a tool that excels in it - the Jasper JSP compiler used by Tomcat, Jetty, GlassFish and likely also by all others. There is an easy way to tweak it to produce whatever output you need nad to transform a JSP into whatever form you want, including an object model of the page:
  1. Define a Node.Visitor subclass for handling the nodes (tags etc.) of a JSP
  2. Write a simple subclass of Compiler, overriding its generateJava() to invoke the visitor
  3. Subclass the compiler executor JspC overriding its method getCompilerClassName() to return the class of the Compiler of yours
Let's see the code.


Continue reading →

Version hell with JSFUnit, Arquillian, and (embedded) Glassfish and other containers

JSFUnit and the JBoss Arquillian test framework for JavaEE look very promissing, but according to my experience there are good reasons why they are only beta and alpha versions. May be you can get them working but you must pick the right version of each dependency - for many things change between individual versions at this point - and be lucky to hit one of the "happy paths". At the end I nearly got JSFUnit 1.0.0.Beta1 running with Arquillian 10.0.0.Alpha4 and glassfish-embedded 3.0.1 but failed to deploy due to a strange parse exception of an arquillian's web fragment. I record this failure to help those who are struggling with this too.

There are the following fatal constraints:


Continue reading →

Most interesting links of May

Recommanded Readings

Acceptance testing / Specification by example:
Continue reading →

Ivy: How to Retrieve Source Codes of Dependencies

Summary: To download sources you must map the dependency's conf also to 'sources' (ex.: conf="myScope->default,sources").

If you are using Apache Ivy (2.2) for maintaining you dependencies, you may also want to retrieve source codes (or javadocs) of those dependencies, e.g. to get nice help pop-ups in Eclipse or to actually browse the sources. Provided that you're retrieving the dependencies from Maven repositories, the configuration required to enable retrieval of source codes is to map to the Ivy "configuration" ("scope", or perhaps more exactly classifier, in the Maven language) called "sources" (or "javadoc" to fetch JavaDocs).


Continue reading →

Installing Java 1.4 to Mac OS X 10.6

Sometimes you really need java 1.4, mainly because just compiling with -target doesn't protect you from inadverently using an API that only exists in 1.5+.

Continue reading →

Upgrading FCKeditor 2.x to CKEditor 3.x including plugins

Upgrading FCKEditor 2.x with custom plugins to CKEditor 3.x is a challenging task because so much has changed but it is possible. I'd like to share here few experiences from the upgrade and show how to map the most important API use cases from the old to the new version and ease the migration by first introducing a facade for (F)CKEditor APIs.
Continue reading →

Discussion: Agile not suitable for governmental IT?

The recent article Agile will fail GovIT, says corporate lawyer is rather controversial but very valuable. Its value lays not in its claim that agile cannot work in governmental environment, something I quite disagree with, but in its presentation of how (inaccurately) agile is/may be perceived in this environment and of obstacles posed by such an environment to any (and especially to agile) development.

The article reveals a fundamentaly psychological and social issue. It doesn't question the ability of agile to deliver projects much more successfully than waterfall. The laywer, Alistair Maughan, doesn't speak at all about projects' results. He speaks about fear (to bear the consequences of a failure) and constraints present in governmental environment. Thus it's pointless to argue about benefits of the agile and absurdity of the waterfall approaches. The key to a successful project is to understand those constraints, lift them as much as possible, and create a security structure for both governmental officials and the supplier to be able to work within those constraints safely. We shouldn't forget that there are also smart people in the government agencies who will gladly accept a methodology that leads to better results as long as they are safe from being denounced on the front side of newspapers as bad public servants when something goes wrong.


Continue reading →

Most interesting links of April (renewed)

Only two articles this month:

Continue reading →

How stateless can you go?

I've attended an Oslo Coding Dojo named "How stateless can you go?" lead by Thomas K. Nilsson. The goal was to write a toString() method for a tree structure printing nodes with proper indentation w.r.t. their depth and then to make it as stateless as possible without any other regard (such as performance or cleanliness of the code).

It was very interesting to compare the original, stateful version and the resulting stateless one and to see the solution in various languages (Haskell, Clojure, Groovy, C#, Java, Scala) - it looked actually pretty similar in all.

What I've learned is that stateless (i.e. functional-style) code looks much cleaner for you get rid of lot of noise such as local variables and loops. In practice it is important to use a language with an efficient implementation of recursion (especially tail-recursion) and with data structures that lead themselves easily to recursive processing, i.e. make it easy and efficient to process the first element of a collection and do that recursively for the rest without modifying the collection (and providing utility methods like each). It is of course best to have languages that support map/reduce.

You can check the slides and various solutions at GitHub and see our primitive and stateless implementations below. (We did it in a nearly TDD-manner, but I won't include the test here as it isn't essential.)

Update: There are more solutions linked to from the meetup's comments - search for "github" - and there is also a link to an article series for deeper discussion of challenges in writing pure and stateless code.


Continue reading →

What I've Learned from (Nearly) Failing to Refactor Hudson

We've tried to refactor Hudson.java
Continue reading →

What Do I Mean by a Legacy Code?

I'm using the term "legacy code" quite a lot, what do I mean by it? I like most the R. C. Martin's description in his foreword to the Michael Feathers' book Working Effectively with Legacy Code:
It conjures images of slogging through a murky swamp of tangled undergrowth with leaches beneath and stinging flies above. It conjures odors of murk, slime, stagnancy, and offal.

Continue reading →

Refactoring the "Legacy" Hudson.java with the Mikado Method as a Coding Dojo

I'm preparing a coding dojo for my colleges at Iterate where we will try to collectively refactor the "legacy" Hudson/Jenkins, especially Hudson.java, to something more testable, using the Mikado Method. I've got the idea after reading Gojko Adzic's blog on how terrible the code is and after discovering the Mikado Method by a chance. Since a long time I'm interested in code quality and since recently especially in improving the quality of legacy applications, where "legacy" means a terrible code base and likely insufficient tests. As consultants we often have to deal with such application and with improving their state into something easier and cheaper to maintain and evolve. Therefore such a collective practice is a good thing.

The Mikado Method

The Mikado Method, which the authors describe as "a tool for large-scale refactorings", serves two purposes:
Continue reading →

Copyright © 2024 Jakub Holý
Powered by Cryogen
Theme by KingMob