This Site Has Moved

New Wordpress Site

The Old/Non Updated Content...




The home of the haikulator

 

Links

Sentence Generators
My Stand-up & gigs
The Coding Craftsman
BurberryAndBroccoli
MarkInventions

The Musical!
Incredible Productions

apostrophell
backlash
incredible
haiku


Previous Posts

Oh What A Feeling
Not The Best Start
I Should Be Asleep
It's A Mystery
The Day of the Contingency Plan
Addicted to Work
Darting Hither
It's Not Always Gigs
I Can Do This
A Convenient Truth

Blog Archives

October 2001
November 2001
December 2001
January 2002
February 2002
March 2002
April 2002
May 2002
June 2002
July 2002
August 2002
September 2002
October 2002
November 2002
December 2002
January 2003
February 2003
March 2003
April 2003
May 2003
June 2003
July 2003
August 2003
September 2003
October 2003
November 2003
December 2003
January 2004
February 2004
March 2004
April 2004
May 2004
June 2004
July 2004
August 2004
September 2004
October 2004
November 2004
December 2004
January 2005
February 2005
March 2005
April 2005
May 2005
June 2005
July 2005
August 2005
September 2005
November 2005
December 2005
January 2006
February 2006
March 2006
April 2006
May 2006
June 2006
July 2006
August 2006
September 2006
October 2006
November 2006
December 2006
January 2007
February 2007
March 2007
April 2007
May 2007
June 2007
July 2007
August 2007
September 2007
October 2007
November 2007
December 2007
January 2008
February 2008
March 2008
April 2008
May 2008
June 2008
July 2008
August 2008
September 2008
October 2008
November 2008
December 2008
January 2009
March 2009
April 2009
May 2009
August 2009
September 2009
January 2010
March 2010
April 2010
May 2010
June 2010
July 2010
August 2010
September 2010
October 2010
November 2010
December 2010
January 2011
February 2011
March 2011
April 2011
May 2011
June 2011
July 2011
August 2011
October 2011
December 2011
February 2012
March 2012
April 2012
May 2012
June 2012
July 2012
March 2013
April 2013
May 2013
June 2013
July 2013
August 2013
September 2013
October 2013
December 2013
January 2014
February 2014
March 2014
May 2014
July 2014
January 2015
February 2015
March 2015
April 2015
May 2015
June 2015
July 2015
August 2015
January 2016
February 2016
March 2016
April 2016
May 2016
July 2016
August 2017
January 2018
August 2018
September 2018
July 2019
August 2019
May 2020
June 2020
July 2020
August 2020
September 2020
December 2020
January 2021
July 2021
September 2021
February 2022

Thursday, October 16

Unnecessary Ironing

Isn't it ironic? No, it's ironing. Ah yes. I have often found that my work life and home life can follow similar patterns. For instance, if I clear my desk at work, I'll come home and clear my desk at home. Given that, on Monday night, I destroyed the last nice desk I owned (from my Newcastle house), I'm feeling a bit tender on the whole desk subject, so let's drop that one for a moment.

Today had a much closer home/work connection, since I ditched the office at 11am and, after an early lunch in which I bought a casual blazer, came home to do a day's work. In fact, for some reason, I did more than just the working day's work. I kept going until much later than planned. I got into it.

A reshuffle of the evening's activities ended up occurring to cancel the painting and dig deeply into the laundry pile to discover all those garments I thought I'd lost, and which turned out to be simply hibernating in the big basket I'd wondered what I'd put in.

I ironed for a long time. In the end, I took on some ironing tasks I never take on. I ploughed through some bed linen. This is nice bed linen, which I've only recently bought, so why not make it look nice - it will, hopefully, go on the bed very well next time. But it was unnecessary. But it was a nice-to-have.

Perhaps nice-to-haves are best described by the term unnecessary ironing. You can see why a nice-to-have is nice-to-have. That's how it got its name, but is it absolutely essential? Is it worth the time?

It occurs to me, as I weigh up what I made on my computer today, that the end result was ok, but not much more than just that. Ok. I made something that I didn't think I could get anywhere else, and which I reckoned would save a bunch of time to have. Thing is, there's a reason why people haven't made it, and there's also a question in my mind over whether we'll ever "earn back" the time I've theoretically saved by making this thing.

From my position right now, I can see how the method I was going to use for another thing, which seemed to justify the "need" for this particular tool, might be better off changed to something else, which I know doesn't need it at all.

D'oh!

Still, I got to flex my muscles as a programmer and I like being a programmer. I've said it before and I'll say it again. It's what I do. In particular, the use of unit tests (not enough of them, mind) and TDD was a very useful way to solve this particular problem.

I have "hero" tendencies. This means that I want it to be my line of code which saves the day. I also have blustering as a character trait. I was more determined to do this particular thing because it was suggested that it wouldn't work. Again, in the cold light of day (or in this case, the soporific miasma of late night contemplation) maybe there are reasons why it's not all that good, but it's also pretty good. Do you care what it is? Oh well, if you don't, then ignore the next bit and stop reading.


Imagine an XML file:

<Configuration>
<name>Ashley</name>
<point><x>12</x><y>34</y></point>
<pets>
<Dog name="rover" />
<Cat livesRemaining="8" />
</pets>
</Configuration>


It's a simple configuration file. There is a property of the configuration called "name", which is a string, another called "point", which is some sort of tuple of "x" and "y", then there is a list called pets, of which there is a Dog and a Cat. Sometimes properties are expressed in attributes, sometimes they're in sub-elements. It's an anything-goes kind of a file.

You could write a mapping from this to some appropriate class structure, along with schema validation. You could. Or, you could create some classes:


class Configuration
{
String name;
Point point;
List pets;
}

class Point
{
int x;
int y;
}

class Dog
{
String name;
}

class Cat
{
int livesRemaining;
}


Then you could use the code-generation facility of most IDEs to generate the getters and setters for all of these values, giving you a series of POJOs/DTOs/VOs, whatever you want to call them. My code will just let you point your XML at the starting class. It can tell that the xml element "point" has a counterpart in the "Configuration" class and can, therefore, infer what object to create to go in there, and, thus, how to populate its Xs and Ys. For the list, it creates a simple list and guesses at where to find the classes (same package as the owning class) that are mentioned in the xml.

It's mapping-free XML to object mapping - it's unnecessary ironing:


// load the object from the file
Configuration config = (Configuration)HlxUnmarshaller.loadFrom(file, Configuration.class);


I called it HlxParser, which is short for "handy little xml parser" or, more likely "hateful little xml parser". It's sure to piss people off. It works, though... as far as it goes! It'll be a bitch to debug!

0 Comments:

Post a Comment

<< Home

All content ©2001 - 2020 Ashley Frieze