Skip to main content

Posts

Item 57 - Use Exceptions only for exceptional conditions

Using exceptions only for exceptional conditions is something we can all agree with. However, this item should have been named "Don't use exceptions for control flow and how to decided between state-testing method and distinguishing return value". Bloch gives an example of how exceptions can be used for ordinary control flow, two alternatives in state-testing method and distinguishing return value and how to choose between them. I was rather hoping for some discussion of what exception conditions are, not just a brief discussion of what they are not.

Java Dependency Management with Ivy Part I – The Basics

Along with the rich enterprise libraries that come as part of the language, one of the biggest advantages of Java is the vast number of third party libraries available. For example if you are writing an enterprise web application, GWT, Spring and Hibernate provide a framework with a huge amount of pre-existing functionality. The size and number of dependencies grows as your application grows. GWT and Spring alone, without their dependencies, are more than 7MB. The ideal place to put dependencies is in a source control repository as part of your project so that when you or your continuous integration server check out the project for the first time all the dependencies are there. Then you don't have to go and get them and store them locally in a location that is agreed by the entire development team. Storing the dependencies for a single project in a source control repository isn't too bad, provided there is plenty of room on the source control server.. However, if you have mo...

Item 55: Optimize Judiciously

Bloch gets this item so right! He includes some famous quotes about optimisation and of course the most well known one: We follow two rules in the matter of optimisation: Rule 1: Don't do it. Rule 2: (or experts only). Don't do it yet. But Bloch doesn't leave it there. He goes on to summarise the rules with "measure performance before and after each optimization attempt." We all know this, but how many of us actually do it? Actually I've seen these rules put to bad use and Bloch covers that too when he points out that you should still be thinking about performance issues when writing code. The example I've seen is someone retrieving a lookup table from a database for each iteration through a dataset, rather than reading it once and caching it. At least that optimisation was straight forward. The new information that surprised me a little was that it appear to be accepted that Java does not have a strong performance model. We all know Java is traditionally...

Item 49: Prefer primitive types to boxed primitives

This is the first item, certainly that I have reviewed, where I feel Bloch has it spot on. There's no arguing with this one! Bloch points out that Java has a number of primitive types such as int , double and boolean and each of these types has a corresponding reference type: Integer , Double and Boolean . These are the boxed primitives. Auto-boxing and auto-unboxing was introduced into the language in 1.5, so the Java programmer must now be more mindful of their use. There are three main differences between primitive types and boxed primitives: Primitives have only their values, whereas boxed primitives have identities distinct form their values Primitive types cannot be null , but boxed primitives can Primitive types are more space and time efficient than boxed-primitives Care must be taken with using the == operator with boxed primitives as, with any other reference type, it compares identity and you almost certainly want to be comparing value. If a boxed primitive is compa...

ACCU Conference 2010 Proposal (2): Java Dependency Management with Ivy

Type: case study Duration: 90 min Speaker name: Paul Grenyer Speaker Biography Paul has been programming in one form or another for over 20 years. After several years using C++ and a brief period using C#, Paul is now happy somewhere he hoped he'd never be, programming in Java. After time in industries such as marking machinery, direct mail, mobile phones, investment banking and Internet TV, Paul is currently working for an exciting new company based in Norwich where he heads up an ever growing team of senior and highly skilled people. He has been an ACCU member since 2001, a regular publications contributor, including the now well established Desert Island Books column, creator of the mentored developers and a committee member for most of that time. When he's not programming and family life allows, Paul thoroughly enjoys science fiction, heavy metal and cycling. Description One of the biggest advantages of Java is the vast number of third party libraries available. As the si...

Bloodstock 2009

This year was one of the best Bloodstock s ever, which surprised me as the line up didn't look too strong. I haven't come away with a list of bands I want to buy all the albums of, but I did enjoy a lot of the performances. Insomnium[6] sound a lot like Swallow the Sun and Paradise Lost. They put on a very good show. I find a lot of old thrash bands quite boring, but Sodom[5] were quite good. They could have done with a second guitarist and the bass broke in the first song and it seemed to take ages to get it fixed. Saxon[8] gave us some some classic traditional heavy metal. Solid, as expected. The best bit was, following the guitarist standing on a monitor, Biff Bifford ripped off the sign saying "DO NOT STAND" and showed it to the audience. Once their sound was sorted, Arch Enemy[10] stole the show. They turned out not only to be the best band of the day, but of the festival, but then that's what you'd expect from Arch Enemy. Carcass[4] were very disappoin...

Century Rain

by Alistair Reynolds (978-0575076914) Alistair Reynolds is still by far my favourite author and he never fails to amaze and surprise me. I've said it before, and I'm sure I'll say it again, but nothing else he's written, for me, gets anywhere near as good as his Revelation Space series. I'm sure it's just the lack of scope of a stand alone novel compared to a series. I enjoyed Century Rain, but I don't think I'll read it again. The ending was rather cliché and I think I'd rather have seen the bad guys win for a change, although it wasn't clear to me when they were trying to wipe out the ALS, I probably missed it somewhere. This book is a lot easier to follow than the Revelation Space novels. In a few books time I'll be reading House of Suns. Hopefully this will live up to Revelation Space.