OU blog

Personal Blogs

neil

braking or barking?

Visible to anyone in the world

I'm in that post-festive phase of trying to get my sleep-pattern back to base-normal [for work] and my manic alcohol consumption under control, by a reducing-my-ridiculousness-slowly policy. You know the one I mean; it's the one that you try with your debts—as long as you are borrowing less you are headed in the right direction. Hope before sense.

I've completed all, of the few, Yule-enforced social events that are necessary for me to prove that I'm not a complete whacko-hermit. Now I'm freed up to watch endless repeats of Doctor Who, Merlin and Once Upon a Time from the comfort-trap of my couch, dangling a glass in my hand. As ever this leads me to feeling useless uselessness and twatitude.

I can't seem to do any maths, so when I got up this afternoon, I decided that I'd do some Java stuff, after all, if I haven't completely ruined my credit with the OUSBA, I'll be taking a course that involves this soon. I'd create an Unlimited Register Machine in Java!

I decided on an agile strategy, for it suited my laziness. [To be fair to me, I have done some work on this before and I had done some pre-planning. This isn't quite as half-arsed as it reads.]

The first thing to be done was to work out how the commands would be implimented. At first I'd thought about individual classes but I soon saw that these would be better as static methods of a Command class. What would I pass to these, what would they return?

So I thought about about a State object, not quite generic but close. That would work! We can pass a State to a Static Command method and get a new State back so that the URM object could change its internal state, which wouldn't be a State but its state of course!

I'm still testing the beast but even if it needs tweaking it will work. Whether it will work when I've introduced it to other URMs I don't know.

What's annoying about all this is that my quick-and-dirty JavaScript is just better at what I've achieved today. If this doesn't get better I'd have been better watching another three Doctor Whos and having multiple more drinks.

Fortunately I'm pretty sure that I can make this better.

Drunk again.

Permalink Add your comment
Share post