What a year… Scratch that – what a couple of years!

So I started this blog thinking to concentrate on Java programming & related fields but Things Happened and I forgot I even had this. The only reminder I had was when the domain came up for renewal. Apologies. I’m thinking this is going to be re-launched again soon. Bit of a false start. Basically, in 2020 my father was diagnosed with vascular dementia stemming from a number of TIAs and strokes. He was taken to hospital, whereupon he went into an effective communication blackout. He didn’t have nor was he able to operate a mobile phone, and it was next to impossible to get any updates or any contact with him on the phone. You ring the hospital, the phone’s engaged, every damned time. I had to write to my MP, Jack Dromey.

*Sigh*

Yeah, so my dad was taken from the hospital to an old folks’ home, and then swiftly back to the hospital because he was shitting the bed, and then to a care home – there’s a difference: a care home is staffed by nurses & they know how to deal with old folks as patients needing 24 hour care rather than just slightly doddery old people who just need an eye on them from time to time. Because of the COVID pandemic we couldn’t visit, and my father’s condition deteriorated rapidly. We had 2 video calls with him, during neither of which was he particularly responsive. Then on May 16 2021 we got a call saying he’d been taken to hospital again, and the care home’s doctor told us to get our arses down to the hospital, because he was “Very Poorly” (Doctor code for “Dying – go say your goodbyes”).

We got to the hospital with my mum, meeting my sister & her 2 kids at the door. He was emaciated, unconscious, breathing laboured. Then agonal breathing. Then dead.

Ever since, I’ve been trying to sort out probate. He was cremated, in a non-attended, no-frills cremation. I got him a good urn. Items of his jewellery have gone missing since he was taken to hospital in 2020.

Now my mum’s in hospital & we haven’t yet sorted out third party access to her accounts despite having LPA over her. I do not want this to go the same way as with Dad.

Meanwhile I’ve still been working, as a Java developer. I just can’t be bothered once the working day is over though. What’s the point when we end up like this?

Anyway, I’ve sussed how to get back into the blog, and hopefully I can get round to formulating some stuff for it. Over the summer I started learning about EMACS and Clojure – and org-mode in EMACS which is a game changer. I’d quite like to do something about that. I have notes in an org file. I have to MOT the car & sort things out around my mum though. Might be a week or two.

Spring MVC

Hi – My name is Matt Moran. I’ve been working for a couple of years at a company in my hometown of Birmingham, as a back end Java developer. One of the core technologies we use is Spring. Spring simplifies a lot of things – it enables you to do dependency injection (DI) also known as Inversion of Control (IoC). This lets you design classes independently, loosely coupled, with the dependencies assigned at run time. Spring has APIs that allow you to do your data access layer easily, and to create an application using the Model/View/Controller pattern.

I’m aiming, over the next few weeks, to demonstrate these principles by developing a simple web app that will create, read, update and destroy records on a MongoDB database using simple web forms set up with Thymeleaf and HTML. It will be called Matt’s Library Database System, since when I first got into IT many, many years ago, one of my first jobs was to design a library catalogue system.

Let’s sketch out the data model for this. Initially, let’s just store records for books. Let’s call the record (or document as MongoDB calls it) Book.

Example book:

{
   "book":{
           "title": "The Joy Of Clojure",
           "authors": {
                       "Michael Fogus",
                       "Chris Houser"
                      },
           "publisher": "Manning",
           "isbn": "1-6177291=41-2"
          }
}

…is how I would put it in my rough, hand-written JSON.

At this point it occurs to me that this might work better in Groovy than Java. Groovy’s a JVM language – it runs in the Java Virtual Machine – and it compiles to Java bytecode, so it’s compatible with pretty much everything else that runs in the JVM. The main differences with Java is that Groovy does a lot of stuff automatically, behind the scenes, and I kinda like that – it means a LOT less typing!

For instance:

Our book, in Java, would be represented as:

class Book {
   private String title;
   private String[] authors;
   private String publisher;
   private String isbn;

   public String getTitle(){
      return title;
   }
   public String setTitle(String title){
      this.title = title;
   }
   // further getters & setters here
   // for every. single. field!
}

…whereas in Groovy, getters & setters are implied, giving us a 6 line class. So much less hassle!

But Java is what I do, so initially at least let’s do this in Java, and then I’d like to refactor to Groovy once we’re done.