Handling validation on Entity properties

Grails GORM (Grails Object Relational Mapping) allows you to define a number of validation rules that are carried through to your view when entering data.

For example with following simple Entity:

<code>
class Test1 { 
    Long id
    Long version
    String string1
    Long testLong
    Float float1
	
    def constraints = {
        string1(blank:false)
        testLong(nullable:false,blank:false)
        float1(nullable:false,blank:false)
	}
...
}
</code>

The ‘constraints’ section defines the rules on the properties on this Entity – the rules are a comma separated list of name/value pairs for the rules to be applied. Notice the ‘blank’ only works on String properties. To require a value for any other property type, use ‘nullable:false’.

Here are some further self-explanatory examples from the online Grails docs:

<code>

   def constraints = {
          login(length:5..15,blank:false,unique:true)
          password(length:5..15,blank:false)
          email(email:true,blank:false)
          age(min:new Date(),nullable:false)
   }
</code>

X-develop – comments on an ‘unknown’ IDE – artima developer

Geert Bevin, known for his work on the full-stack open source framework ‘RIFE’, has an interesting post on artima developer about an interesting sounding IDE that I’ve never come across before called X-develop.

Geert mentions a couple of benefits of this IDE that I realize now seeing them in writing I find extremely infuriating with Eclipse – X-develop gives you ‘permissive’ code completition that still works even if you have compilation errors (which not many other IDEs including Eclipse do not), and the IDE itself takes up minimal screen real estate, something else that drives me crazy with the different perspectives and views in Eclipse.

Another cool feature which I would love to see in all IDEs (I’ve only read about this but have never seen it in an IDE before), is ‘back in time’ debugging, which allows you to step backwards through your code as well as forwards. This is an awesome feature. One of the most annoying features in current debuggers is that you are stepping through your code looking for that one particular place where you have some bug, and then you step too far by mistake and you miss it, and now you have to start again to get back to that one crucial place. If this feature is what it sounds like, then it would allow you to step back to previously executed code to see where you came from – that is an awesome timesaving feature.

Five Habits of Highly Profitable Software Developers – java.net

Robert Miller has an interesting and useful article on java.net today that lists and describes 5 habits/guidelines for developing effective Java code.

The list is not earth shattering, and I’ve worked with variations of these guidelines both as a developer and as an architect defining guidelines/code standards for a project, but if you haven’t come across these ideas before then they certainly can help towards creating simpler, easier to maintain and understand code.

Sony corrects PS3 shipping volume numbers

After this week’s news that production has not yet started on the PS3 which is due to start shipping worldwide in November, Sony has confirmed the shipping numbers. They are planning on 2 million units to be available for the mid-November launch, with a further 2 million available for end of year 2006.

Something is strange with this annoucement as it doesn’t seem to fit with the fact that Sony has said they are not yet in production – time is counting down, and if they haven’t started production yet they don’t have much time to get 2 million boxes out of the door.

I can only imagine that there is some marketing strategy going on here, and by giving consumers the impression that they will be in short supply on day 1, people will be camping out over night to get their hands on one, and therefore helping increase demand. Isn’t this exactly what Microsoft did with the limited numbers for the XBox360 launch?