Page 19 of 42

Note to a friend

I think that I did’t explain the whole suicidal thing properly. When I said I wanted it to stop, I meant the grasping and yearning for things. It occurred to me in the car on the way to work I had’t explained it properly.

You see a pretty face and want to follow it, you hear of wealth and freedom and you want it, you are stuck bored out of your mind when you’d rather be writing songs or anything else.  I don’t just want these things with a kind of “would’t it be nice”. I yearn for them – a terrible hunger that drives me nuts. I think it drives us all crazy but most people are’t aware of it.

It’s the wanting I get tired of. That barrier between self and other. The wanting the other to be complete. That’s when oblivion starts to look appealing. But I’d rather look for Nirvana, where the flame of wanting has been blown out, and you can just be. Without all of the other crap. And help others with their pain.

Nirvana is a tall order.

But that’s what I meant anyway.

Scallywag thieves

Trying very hard to be a Buddhist but …

Jon was playing in the park with some of his mates. Sitting chatting and an older boy ran up and “borrowed” his bike. All £350 worth. It was paid for by Jon from accumulated years of birthday money, and he really loved it. Cycled off with his mate. Both lads around 16, dark hair, skinny, wearing blue and grey striped shirts. Jon described the thief as “looking a bit simple”, whatever that means.

We drove around (as did one of the other dads) but the scumbags were long gone.

So, if you live in the Birkenhead area and someone offers you a black Giant GTX bike with a non-standard chain guard. Please contact me with the details and I’ll pass them on to the police.

All my life I’ve been on the receiving end of this kind of thing – they were very lucky I did’t find them because I’ve calmed down now. Fancy being on the receiving end of my lifetime’s worth of anger and irritation – bet that would hurt. I’m also glad I did’t find them, because I’d have had to face the consequences of acting out my anger and that would have been bad. They were very lucky that Jo’s friend’s dad did’t find them – he was incandescent with rage at people picking on 12 year olds, and does’t have my religious beliefs!

Hey ho, rang police, will make insurance claim etc. etc. etc. Now we can’t go cycling at the weekend on our holiday – very annoying.

Waiting for the cops to call because they are supposed to call if a theft has witnesses … yeah, well, maybe … 21:30 now. 

Old poem that no longer fits in Archive Fragments

It’s dark now

(o where are you sweet knife)

(I hear) singing in the street

(with your bitter edge)

(Out) in the shadows of the night

(little blood gush orange juicy)

Pastel neon dream away

(cut me now, cut out the endless pain)

No sleep again – so lonely next to you

(sweet knife cake cutter)

Cut me now

(rain again to wash it away)

Come again some other day

(rain rain)

16 October, 1998

Suicide Watch

My mind has been in a strange state for quite a while. I’d be lying if I said I was suicidal, but the thought of suicide keeps cropping up. It’s more of a call to me to understand death properly and maybe come to terms with what happened with my father’s suicide when I was 8 years old.

I will be 48 next birthday, so this time next year it will be 40 years. I remember it was spring or early summer. I’m sure that I could find out the exact date because he was relatively well known and it was in the papers at the time.

His act was never intended to hurt anyone. This is the irony of it all. He thought it was for the best – what pain he must have been in, poor man. It beggars belief. Recently my darling son helped me discover that if I am rejected it makes me fly into a rage. Now I know to try and catch hold of it. I think that this is because of the pain that still resonates after all this time and shapes my personality.

I fell out with my sibling because of this, my anger got away from me. There was a whole lot of buried stuff from more recently, say 30 years, that I had forgotten about – because it was embarrassing and humiliating to remember it – and suddenly it was important, then their carping and constant criticism made sense. I was rejected, in a calculated and very clever way. I responded with this unknown rage, a bad bad bad idea, and we can no longer communicate. This makes me feel terribly sad, a dear friend reminded me that this life is too short for this stuff. But my sibling manipulated me into giving them what they wanted – they are much cleverer than me, but what use is it?

All I have left of my father, at least directly, are some silver cuff links with a fish motif. He was a psychiatrist and wrote some books that were classics in their day. They were later brought up to date by a colleague and became Fish’s Outline of Psychiatry and some other titles that escape me now but I have my mother’s copies of them on a shelf somewhere.

He was a good man and did his best. My mother told me that one of his patients had said to her how much he had helped. But in those days, 1968, there was no proper treatment for manic depression. The modern drugs that everyone gets worried about did’t exist. Depressives would eventually do themselves in unless they were watched very carefully, and of course his position as Professor made it hard to insist that he went into hospital under supervision during his final days. We no longer remember wards full of people with catatonia and other distressing conditions because the drugs stop it happening.

I did’t get his intelligence. I am quite clever but not in his league. Not sure that I care about this very much. It did’t do him much good. Nor my sibling.

The lesson he taught me:

First you must learn to love and forgive yourself before you can love anyone else.

I paid a high price for this knowledge and now try to live by it every day. Now I am aware of the unconscious rage it no longer controls me. Just makes my tears flow.

If anyone gets a little comfort from these words – good. 

Blessing all. 

Easter

Got a lot done over Easter but pretty busy.

Rosie was away at a Canoe Camping Club meet near Retford (Notts or thereabouts). We only have one car now so I drove over, camped for the night, drove back and then picked her up on Easter Monday. I managed to take a wrong turn and it took me an extra hour to get home on Good Friday – hey ho. Thursday night was really cold too.

Took Jon cycling at Delamere on the Saturday.  My poor old mountain bike is in need of some TLC and I had the interesting phenomenon of watching the front wheel turn one way when I’d turned the handle bars in another. This was going over a small jump. I was’t injured because us old folks take that stuff fairly easy y’know. Bit embarrassing. As the old guy I was supposed to be carrying tools. Apparently tools are an old guy thing. Another dad (surprise) lent me some alun keys he just happened to have on him, so I suppose the kids’ thesis is correct.

We went to the Yorkshire Sculpture Park on the Monday on the way to pick Rosie up. Only got about an hour in there and would have liked to spend quite a bit more time. Kidded D&J that one of the groups of sculptures was bits of an alien space ship and the big one by the lake was them writing “Help” but in odd letters.

I’ve been reading a lot recently. Still working my way through Living without Regret, (see end of last entry). Enjoying is not quite the right word, but it’s giving me a lot of food for thought. Ask yourself: what does mindfulness actually mean on a day to day basis? Can you remember what you had for breakfast? Your journey to work?

For my technical reading I finally succumbed and bought myself a copy of Martin Fowler’s Refactoring – great book. Read it over the weekend – I am that sad, sorry. I can read a big thick technical book in a few hours if it interests me. At least 2 ideas came out really strongly: the null object pattern, and the strategy/type patterns – as well as the interesting idea that a big comment is probably better replaced with a well-named method. Back to the defensive programming theme of the last blog entry he says it’s really important not to break your contract with the user and actually throw exceptions. I’m still thinking about exceptions and how to do it properly.

Saw some excellent code today – laughed my socks off:

if ( var == null || var.equals(“”) == true ) return ;

If you are a Java programmer and don’t know why that’s funny you need to get some more training. This was mixed in with lots of

if ( var == null || var == “” ) return ; 

Which is just wrong, assuming that var was passed as an argument and not initialised in the same piece of code. It really irritates me that I tried to find a job as a Java programmer for quite a while and here are these “Java specialists” writing such utter rubbish. Not to mention testing a private list variable that only has one access path to see if it had somehow got some objects in it that were’t the expected type – utter utter rubbish.

For reference the correct idiom is

if ( var == null || var.length() == 0 ) return ;

I also finally got the Ruby pick-axe book. Interestingly, I was choking a bit at the price Amazon were asking and found the Fowler book on The Register books  for 40% off, whereas Amazon were only offering 20%. The Ruby book was £5 or so cheaper too. If you’re looking for a popular computing book I suggest checking the reg out – just put the ISBN in and see. In essence I paid what Amazon were asking for a used copy for a brand new one, added in the Ruby book and got free postage. Good service, too.

Spring

Still trying to find 5 minutes to do something with this framework. Life (and selling a load of old crap on ebay) keeps getting in the way. I think Spring and Rails have a lot in common.

Archive Fragments

Got another section done – starting to get a bit knotty now. I’ve junked probably 50 pages of interesting but not relevant stuff. Need to get some head space and work on it a bit more. Problem is – I get home, I eat, I wrap ebay stuff I do blog entry because I think it will only take 5 minutes and suddenly it’s 10 pm and my 6 am wake up is looking very soon … work is getting in the way of doing interesting things … no change there then.

Foo Fighters

Been listening to In Your Honour almost constantly since January, particularly DOA. I want it played at my funeral, I’ll be laughing even if no-one else is.

When I can get the energy I’ll update this blog with some photos… 

Finding bugs in Java code, Hibernate and so on

Find Bugs

Highly recommend findbugs , we’ve been using it at work for a week or so and it finds lots of bad practices and naive code. Like me, in the last post here, it does’t like returning null all the time either. It recommends empty strings or empty arrays. Can run as a GUI, command line or Eclipse plug-in. We are going to write a batch file to integrate it into our source code control system and make it part of the code audit process as things are checked in.

Hibernate

Good tool , but I wish they’d stop trying to push EJB with it. Nasty dead technology that hurts to use.

Better Faster Lighter Java

Recommend this book . Buy it if you are doing anything with Java. I think the content is probably OK for non-techies as well, at least the first half of the book.  One of the authors wrote Bitter Java and Bitter EJB. These people know what they are talking about. I might even buy the pragmatic book on JUnit.

Exception handling in Java

Still trying to find a good clean way of handling exceptions. I remember reading something about Bruce Eckel of Thinking in blah (replace blah with C++ or Java or whatever) fame. TIJ is worth downloading and having around. I need to find some time to do some digging. Of course, there’s the obvious – just use Ruby on Rails and pass exceptions through to the flash handler, Struts does something similar when every exception has’t been eaten by a catch to be fair. Not sure that RoR is prime time yet. Some folk have told me that Rails does’t scale, but I do wonder if that’s the older version that’s now defunct. I can’t see why it wo’t, particularly if you are deploying under Apache.

Spiritual stuff

Highly recommend Living without Regret. About half way through it. I’m beginning to refocus on my Buddhist beliefs after a long time in the wilderness. This book is a good reminder and has made me think about some things. I underlined the piece about the 4 gates to freedom (p25):

  • Forget the Past. Walk away from the past and treat it like a city you have visited a long time ago.
  • Participate in what is happening now, do not hold back.
  • Drop any sense of I.
  • Let go of all notion of the future

The last point is about focussing on staying in the now. I don’t think it means don’t plan or think about the future – just stop yearning about it and being unhappy. Treat the future like you treat the past. I need to talk to my Dharma teacher but it has been so long I feel embarrassed. I know he wo’t mind, but that does’t make it any easier for some reason.

What defensive programming is and isn’t

This is a tech rant so ignore it if you are’t interested.

Defensive Programming

First, a definition (my understanding):

Defensive Programming means:

  • Not trusting the inputs to your methods/modules and validating them – throwing exceptions for unexpected input.
  • Every if should have an else. This is a caricature on my part, a more pragmatic/sensible approach is if you have a lot of if … else if … or a case statement, always put a trailing else or default that throws an exception if you think you have handled every valid case.

This is programming by contract/invariant under another guise, perhaps a little simpler. The second point can be a total pain if you use testing tools that insist on testing every path through the code, because you have to somehow pass invalid input through.

Look at the following allegedly defensive code. I would argue that this is not defensive, because it does nothing with the invalid input:

void bing(LogObject logger) {
    if (logger == null) {
        System.err.println(“logger was null”);
    }
    LocalLog log = logger.getLocal(“bing”);
    // … blah
}
 

So … you’ve logged that the logger is null but carried on to where you’d get a null pointer exception. Why? Either throw an exception, or let the exception throw itself when the getLocal method is called. I have spent most of the last 2 days removing this kind of nonsense from thousands of lines of code. Let’s look at another example:

boolean isSet(String testString)
{
    if (testString == null)
    {
        return false;
    }
    return (testString != null && testString.equals(Constants.ON)) ? true : false;
}

Assume  that Constants is a class that has some string constants defined in it.

I want to kill you! NOW! This is one of the worst examples I’ve seen of just not thinking properly. The defensive part is trying to handle the potential null, but it has been done in a really idiotic way:

  • Why test for nullity twice? Will something change the value of the object reference before it gets to the return statement? Is the Java virtual machine inhabited by pixies that change what an object reference points to between statements just for fun?
  • The expression inside the brackets by the return statement is already a boolean – why use the conditional expression?

if ( true ) return true ; else return false ;

Are you insane? I’ve seen this a lot in Oracle PL/SQL code as well. A boolean is a boolean is a boolean. 

  • If you have read Effective Java you will know that  the equals method tests for nullity in the passed object anyway. The problem is the potentially null testString will not have an equals method. You do trust that your own constants are not null,  pixies excepting. So rephrase to

return Constants.ON.equals(testString)

This is defensive because it handles the null case and it also handles all of the cases where what has been passed is’t a string (not likely in this scenario though). It’s also clean and not obscured by silliness. This leads to a common Java idiom where you always put the constant first and call its equals method, rather than the more natural passed object.

Stop returning null

A really stupid Java idiom is returning null if you’ve hit some kind of error condition, rather than throwing an exception. I’ve seen reams of this nonsense:

        try {
            // some really dangerous operation
        }
        catch ( Exception e )
        {
            // Which one of the 5 exceptions was it? you may want to handle them differently
            e.printStackTrace(System.err) ; // least it was logged somewhere !!

            return null ; // or maybe a runtime exception??
        }

Just propagate the exception or roll your own generic one for your app and throw it after encapsulating the real one. This also means the code that relies on you has to keep checking for nullity or throw random null pointer exceptions. This is inexcusable laziness and results in code like I showed before that tests for nullity all the time. Without an exception we don’t know what the nullity means, so we can’t fix it without dredging through the code (which may not even be ours) and put print statements everywhere. Usually these statements are not deleted and everything starts to bloat, especially your log files. Using nulls like this breaks the contract with the caller of the method. Exceptions are part of the contract. The user can choose to ignore them, but you kept your word with them.

So, stop returning null, please. If it’s an error then let it be one. Returning null breaks the encapsulation, because you don’t know what happened without having to go into the offending code.

If you are working with Strings, and you think it’s OK to return an empty string (as in a find method that did’t, say) RETURN AN EMPTY STRING!!! How radical is that? None of this crap

String myVar = params.get(“myVar”) ;

myVar = (myVar != null)?myVar:”“

Which I have written. J2EE designers, yes, I hate you for wasting my time. I end up writing a helper function to encapsulate this nonsense every time. 

Why has this site changed and other stuff

Blog city have changed the way they do the sites and here we have the least worst option I could find. I lke the trimmed head. Anyway, enough of that.

Ruby on Rails

Still like this environment a lot. I feel a bit ahead of the curve in that it’s still relatively small group of developers using it. I like the Ruby language itself as well. I’ve been using eclipse for rails. http://www.napcs.com. You have to do some hand cranking to set up things like calling rake tasks and starting WEBrick. I have’t had a look at rad rails which is also based on eclipse, mainly because the eclipse project settings directories fight with one another and it whines about plugins. I may set up a different Windoze user to try Rad rails – if I can be bothered.

Eclipse

I’ve finally got used to Eclipse. At work I have managed to get it to show a black background after a big fight with it and then managed to lose the settings when deleted stuff by accident. Really glad I followed my own advice and tar-d up my working directory once I’d got a build running, or it would have been a bit tedious. I’ve decided to go with just stopping everything being screaming white and see how that goes. Vim has themes and you can just pick one – why Eclipse is so far behind is beyond me, seeing as the world uses it. I’ve done some reading and this Microsoft/Apple crap about making your monitor look like a piece of paper is very bad for your eyes. The version of eclipse that ships with Eclipse for Rails does’t allow you to colour the text for scriptlets and everything went a bit black until I realised. So I’ve gone for the not-white option at home too.

Work

Bit tired of some of the silliness and the lack of planning. We’ll see.

Archive Fragments

Got some more of this edited/written. I need to think about it and do some planning, which is what I always say.

Even when I’m tired my brain keeps working

Spent a lot of the weekend in bed fighting off a virus that made me really tired. Glad I take supplements, one of the guys at work was off for a week and came back coughing like a 50 a day smoker. I think I got off lightly 

Recast the first 50 pages of Archive Fragments, looking good and tight now. I’m about a fifth of the way through the Rails book as a work book and about half just reading it.

Finished Absolution Gap – cracker of a book, really enjoyed it. It’s always interesting to read stories that make you think about what might happen if people could live for 500 years – what their perspectives would be and so on. Love the idea of the brain being enhanced to run more quickly and go into the quantum. 

Work is sort of fun because it’s new.

<java tech speak> 

We’ve been chasing an irritating bug with the framework we use to build our app. In essence the guys wrote their own IPC using sockets and if a random packet touches one of the sockets they are using it causes an out of memory error which kills sessions and randomly breaks things. A simple config change to use RMI instead, and up the memory to a better aribitrary value from the 100MB default. Bug’s been there for ever but we only just hit it. It took 6 weeks of effort to find an issue our framework supplier knew about already. Sigh.

Did some interesting reading around eden memory and so on, plus Java 1.5 has some sort of elective memory management which is in fact disabled in the app we use. Student’s T test, statistics, rah! Nearly 20 years since I did any of that stuff.

One really annoying thing about the app we are using is that in it’s “raw” state you have to rebuild the whole thing and then redeploy it every time, which takes around 10 minutes. Reminds me of the old days when I was writing COBOL – but I wo’t bore you with that. They also compile all of the JSP’s using Jasper in the build.xml before the deploy. Finding anything that might need to be changed is a total pain. Struts and tiles – really not sure what they give you about from even more XML files and indirection. Ruby on Rails looks better all the time. To be fair I suspect my dislike of S&T is at least partially because I have to keep rebuilding everything and they are’t visible in the eclipse environment because they deploy as part of the framework. Ugh.

If you want EL for all of the attributes of a given map in your JSP:

  <ul>
   <c:forEach var=”k” items=”${props}”>
     <li><c:out value=‘${k}’/> = <c:out value=‘${props[k]}’/></li>
   </c:forEach>
   </ul>

Anything else? Oh yes, I love eclipse but for not being able to make the background black across the whole tool. I read somewhere it’s much better for your eyes and have tried it with emacs and gvim and agree.

JAD

Java decompiler. Excellent tool that there is an Eclipse plug in for. Very useful. 

</java tech speak>

Need some kip now … oh yes. Big weekend in Bradford ahead – Rosie’s mum’s birthday and a conference. Love complication. 

Wot I’ve been doing

Archive Fragments

Got the first 50 or so pages done, in the process of reviewing and carving the crap out at the moment. With a pencil and a print out. Reading parts of the narrative out loud to make sure they work.

Ruby on Rails

If you want to build a database-centric web app in 5 minutes flat … Get hold of a copy of Agile Web Development with Rails and dive right in. This is interesting because I’ve been holding back from it for ages, simpy because I was wary of spending energy on YAPF (Yet Another Programming Framework). Sun have apparently started putting money into it (probably because Oracle bought Zend of PHP fame). It just works and is secure. It’s what a framework should be – I hate the Java and M$ frameworks that make it hard to do anything without and IDE and 20 weeks training. Rails just works, and you don’t really need to know Ruby, although I think understanding what yield does would be an advantage.

I also love Ruby-esque things like

errors.add(:price,”should be at least 0.01”) if price.nil? || price < 0.01

Concise and clear. I also love the idea of having a series of migration objects that update your database and create test data. 

I think it wo’t be long before we have Rails for J2EE, JRuby is already there and you can call out to underlying Java classes anyway. Looks useful and cheap. Testing and so on are built into the framework…