Archive for the ‘Dev Platforms’ Category

Concurrency Strategies for Hibernate Caching

Monday, July 30th, 2007

Caching and concurrency management are tricky. If you have a cache that lives in memory but you have updates to the database that the objects originally came from, how are you going to make sure that the cached objects still reflect the contents of the database?

This really depends on what type of data you are dealing with. Data types that are mostly read (news, notices, articles) probably benefit from whatever caching you can provide, while areas of data that change a lot (shopping carts, server status records) probably won't benefit from caching at all.

Here are the concurrency strategies on hibernate caching explained:

technorati tags:

(more...)

On the topic of assertions

Tuesday, March 6th, 2007

Every assertion should be thought from the standpoint of

  1. What was expected
  2. What actually happened

Translation: assertTrue should always, always have a message.

Consider the following:

 
assertTrue(mv.getViewName()
    .startsWith(myController.getSuccessView()));
 

This will only return "assertion failed". Which is great, but how do we know what happened? If this is buried on one of the lunt automated remote builds, how am I supposed to know what is going wrong? Which is the expected? What actually happened?

A much better version of the same looks like this:

 
assertTrue(
    "Was expecting something like "
        + myController.getSuccessView() + " but was "
        + mv.getViewName(),
    mv.getViewName()
        .startsWith(myController.getSuccessView()));
 

Same assertion, but now it tells me more specifically what's going on and I can fix bugs with it. Once I set this on the test, it becomes easy to see what was going on.

I recently had a Saturday with some other Bay Area developers where we did a lot of thinking about testing, so expect some more advice in the future as I collect my notes.

Remember the goal of unit tests is to "find bugs" (thanks Harry!). An assertion without an associated message merely notifies you that a bug occurred but doesn't actually "find it". As you are writing your unit tests, make sure you find it as well.

technorati tags:, , ,

Wazaabi - XUL for RCP.

Friday, December 8th, 2006

This opens pretty interesting possibilities:

Via TheServerSide:

Wazaabi includes a GUI framework that brings XUL to Eclipse RCP plugin developers and a set of components that link the client-side XUL based viewers and forms to server-side business components. Thus, rich client developers can use XUL to code a GUI, rather than using SWT.

Wazaabi brings XUL to Eclipse RCP based rich client applications

This is an actual XUL viewer, not a similar syntax like XSWT or similar attempts. They use servlets to communicate between the XUL side and your application, to keep the flexibility of sending the XUL to a mozilla browser. Very interesting.

technorati tags:, ,

Cheatsheet: Favorite Eclipse Plugins

Wednesday, November 15th, 2006

This is a quick little cheatsheet with my favorite eclipse plugins and the locations of their update sites. It's so I can get back up and running quickly when reinstalling eclipse from scratch.

  • Eclipse Checkstyle - http://eclipse-cs.sourceforge.net/update
  • Spring IDE - http://springide.org/updatesite/
  • Fitnesse by Band XI - http://www.bandxi.com/fitnesse/
  • Subversion for Eclipse - http://subclipse.tigris.org/update_1.0.x
  • Memory Monitor - http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-ui-home/updates
  • Mylar - http://download.eclipse.org/technology/mylar/update-site/e3.2 (or e3.3)

Also, here's some stuff that I like to install manually:

  • JSEclipse - no offense to the WTP folks, but their JS editor is not that great. This one can understand OO javascript, common ajax libraries, JSDoc and more.

technorati tags:, ,

Graphical Modeling Framework

Friday, September 15th, 2006

Boy don't I know this - in a prior life I wrote a GEF editor for a workflow engine.

Let me be blunt: In the past, creating graphical editors within Eclipse using the Graphical Editor Framework (GEF) was slow and painful. It involved understanding a complex framework and quite a bit of redundant code. That said, GEF is an excellent framework for creating graphical editors because it is model-agnostic. On the other hand, being model-agnostic creates its own problems.

Learn Eclipse GMF in 15 minutes

This is very cool. You can define an EMF model with annotated java interfaces, XSD schemas or an ecore document. The new GMF extends this so it can even create a basic graphical editor automatically. Saves a lot of work.

Using Hibernate Validators with Spring and Hibernate

Thursday, September 14th, 2006

In this article, Ted Bergeron shows you how to use the Validator component of Hibernate Annotations to build and maintain validation logic easily in your Web apps.

Hibernate can meet your validation needs

technorati tags:,

Google Web toolkit

Wednesday, May 17th, 2006

Okay, it's official. Now everybody has a web 2.0 solution.

With GWT, you can develop and debug AJAX applications in the Java language using the Java development tools of your choice. When you deploy your application to production, the GWT compiler to translates your Java application to browser-compliant JavaScript and HTML.

Google Web Toolkit - Product Overview

 
Haven't tried it, but it looks like it would work. Of course, the devil is in the details :-)

Myself, I've been using prototype and scriptaculous "raw" (just some JSP tags of my own here and there) on my web application pretty successfully. Remember, in scriptable languages, testing is key.

You also learn a lot from reading their source code. But if you are source code illiterate (what a handicap for a programmer!) a cheatsheet or documentation can help.

technorati tags: , , ,

DHH: The Accept Header and Rails 1.1

Monday, March 13th, 2006

Over at Loud Thinking,  David Hanson has a great explanation of how you can use the accept header with Rails 1.1.

 

technorati tags: ,

Parse Picasa XML with Rails

Monday, February 27th, 2006

Here's a helper I just wrote for a site of mine. I use it with my picasa XML albums to generate the appropriate links for Lokesh Dhakar's lightbox image viewer trick. You can change it to use your own image views by simply changing the "slideshow" method in the helper.

It is also a good example of parsing an XML resource in ruby. I am parsing most of the metadata so you should be able to do a lot more with this.

(more...)

Curso de Rails: Desarrollo basado en Pruebas

Tuesday, February 21st, 2006

He añadido al curso de rails el capítulo práctico de pruebas de unidad, incluyendo el desarrollo basado en pruebas. Espero les guste, y les agradezco sus comentarios y apoyo a este proyecto.