May 31

Throwing away code again with Groovy

Groovy, Tech No Comments »

I run into a task now and then in which the effort of manually doing something is more than writing a script to do the task for me.

However, at the same time, this task may be a one off, so I don’t want to spend a lot of time worrying about:

  • How elegant the design is
  • How the program handles its memory
  • How readable the code is
  • How generic and reusable it is
  • … and the other many things that you often worry about …

When I was hacking a lot of Perl, I would not think twice… and would open up a and get going. As soon as it worked, I was done.

When in the Java world though, I often found myself spending more time thinking about things, and how I could make it generic etc etc. I had a suddent oversion to writing code that I would maybe rm after it was used.

Now, I can still use Perl (and do), but now with Groovy I am getting the best of both worlds.

  1. I feel that I can throw away code again
  2. I can utilize my large set of Java libraries from with my “script”
  3. I am having fun :)

It is refreshing to have my mind back in the mode of throwing away code. Be-gone!

May 28

Using AO to handle roles

Tech No Comments »

Adrian Colyer (man he is on a role since he started a blog!), has just written about the classic mixed-role cohesion problem.

This is explained in the book Fundamentals of Object-Oriented Design in UML.

The example revolves around a Person and a Dog. You don’t want to tie them together directly, as what about tying a Person and their house, phone, tv, spouse, etc. It never ends.

This is the classic problem with roles.

Adrian shows that his adverb/adjective analogy can fit in here, and in fact we want to create a dog-owning person in this case. However we don’t want them tied, as we also may want an organization that owns dogs etc.

He spells out an elegant way to use AO, and intratype declarations (mixins) to do the job nicely!

* not a person in sight…
public aspect DogOwnership {

public interface IDogOwner {};

private int IDogOwner.numDogsOwned;

public int IDogOwner.getNumDogsOwned() { return numDogsOwned; }


public aspect PersonOwnsDog {
declare parents : Person implements DogOwnership.IDogOwner;

This is why I wanted Anders to allow for mixins in C# :)

Read Adrian in Person owns Dog….

May 28

The advantage of being able to assume tooling

Tech No Comments »

There have been a few talks at TechEd which mentioned XML files for configuration, but blew by them saying “You will use studio….”. I started to realise how much of an advantage this is.

For example, with ObjectSpaces there are 3 files: one for the object model, one for the db model, and one with the mapping information between the two. These files have XSD associated with them, and although you COULD hand edit them, you probably wouldn’t want to. Since the ObjectSpaces team knows that developers will be using studio (ok, only 98%) they can choose to setup the XML in the way that they want too… ignoring usability of hand editing.

If you compare this to the Java side of the house, the JDO group has talked a lot about what to do with the config files. We want to make it as easy as possible for developers to get up and running, so we talk about defaults, if we can have a way so there is only one file, etc.

This is because Java developers dictate this from us. We did the whole deployment descriptor thing with J2EE, and although “tools can generate those”, we learnt that a significant number of developers wanted to hand edit. Even with the popularity of Eclipse and IntelliJ, if you walk around to many developers you will see Textpad being used.

Isn’t it a nice advantage for Microsoft to be able to KNOW that most developers will be using Studio. Not all do of course, especially with the Java developers who moved to C# :)

The good news for Java is that we have a lot of great IDEs that we can use. We aren’t stuck with one.

May 27

ObjectSpaces and JDO

Tech No Comments »

I was just sitting in a talk on ObjectSpaces (Microsofts Java Data Objects). It was interesting to get to see it, and to listen to Luca, the very Italian Program Manager. He was great :)

ObjectSpaces really does look similar to JDO. And it should, it is trying to be transparent persistence.

There were a few interesting pieces of information:

  • Many Files: ObjectSpaces consists of 3 XML configuration files.
    1. OSD: Represent your Object model
    2. RSD: Represent your DB model
    3. MSD: Represent the mapping between the two models

    . This is interesting to see, especially due to the talks on ubermapping file / seperate files in the JDO expert group. ObjectSpaces has the advantage in that they are the one vendor, so they don’t have to worry about vendor extensions!

  • OPath: The ObjectSpaces team originally were using XPath as their query language (their JDO-QL). They had an interesting story in that they showed some queries to their early access partners, and they didn’t like it. “Noone will be able to grok this type of query. Business developers don’t get XPath yet”. They went back, changed the parser to understand a ‘.’ instead of a ‘/’, and the same partners loved it :) So, OPath was born, and it has diverged more from XPath as they realised that a language to query an XML heirachy doesn’t map exactly to the needs of an object graph.
  • ObjectSpaces, MDF, WinFS: There can be only one. These three teams have gotten together, as there was a lot of overlap between them. This is the reason that ObjectSpaces won’t be shipped until Longhorn. You could hear the pain in Luca’s voice. He wants it out there… it has been so long.
  • Reflection / Bytecode: It sounded like ObjectSpaces is all about reflection. They don’t do any of the cool things that the JDO world can do via bytecode. One painful thing that I saw was that you had to change your “transparent” code from an ArrayList to an ObjectList (part of ObjectSpaces), to get lazy-loading to work. I prefer leaving my source code the same, and having someone else munge it to get it to work.
  • Supporting any query: One feature which seemed really cool was the way that they can support you running almost any query (as long as the results have enough info for them to map to an object). Instead of having to use a new type of SQL that uses objects, or forcing a subset of SQL etc… they let you get your DataReader as you normally would in ADO.NET. Then, you simply wrap that reader and you get back to the object world:

    DbObjectReader dbr = new DbObjectReader(sqlReader, typeof(Person), ..)

    I wonder if we could learn from this in JDO.

A great talk, and very interesting to hear.

May 27

Ted, your turn to make fun of the Microsoft bloggers…

Tech 360 Comments »

I was with Ted Neward, my TSS brother editor. He has been teased in the past from people on the Microsoft side of the fence, when they have see the odd Java stacktrace on his blog (Ted wrote his own blogging software, like 90% of people on the planet ;).

Ted. Next time they say anything just show them this: down

Joking aside, it has actually been a pleasure to meet the Microsoft folks. It is really interesting to see that they listen a lot to the Java side of the fence, and they know far too much about

I had to laugh as I heard some of them trying to work out what Inversion of Control was. We need to take a leaf out of their book and:

1. Learn from their ideas (man I wish we had delegates/anonymous methods/closures, and their tools!)
2. Maybe not be so political, and as developers just work together a bit more

May 27

Some Perl Fun: Being a poet, and the Perl 6 Periodic Table

Perl, Tech 12 Comments »

The Perl guys know how to have a bit of fun.

Perl 6 has added a slew of operators (I know, I know).

Mark Lentczner then created the Periodic Table of the Operators

Also, Larry Wall was asked again about the great indentation debate (yes Python-ers, we know you are there). He came back with:

Indentation is a wonderful form of commentary from programmer to programmer, but its symbology is largely wasted on the computer. We don’t tell poets how to format their poetry.

You have to love Larry :)

May 27

Anders Hejlsberg and AOP

AOP, Tech No Comments »

Anders was asked (and is being asked a lot at the moment), what his thoughts are on AOP, and how it will fit in with C#.

Anders is in a “wait and see” mode. He sees a little wary of the fact that “If I look at my code I don’t know exactly what is happening”, as someone may be weaving in. This sounds a little bit like the people that were wary of polymorphism at first, as they didn’t know what was really called. I think it would be good to show some code with and without AOP, and how you get MORE clarity in your code with it (in my opinion). I do think it is wise for Anders to be wary though, but it is good to hear that he is paying attention. He did say that he thought that Attributes were doing part of the job. I worry about people confusing Attributes and AOP.

I think there is room for Gregor to talk to Anders to have a really good discussion. In fact, there is room for this with a bunch of the Microsoft people, who are definitely poking AOP…. and could probably do with some nice information.

May 26

Microsoft, Aspects, and Domain Specific Languages

AOP, Tech No Comments »

Sun has recently shown that they are a little skeptical of AOP. I hadn’t heard anything from Microsoft on the matter, until I got a glimpse yesterday.

I was in a talk by Keith Short on “Tools for SOA”. It turned out SOA (Same Old Application?) was really put out there to lure in the buzzword biters :) What the talk was really about was Microsoft’s vision for modelling. Keith went through where he think CASE went wrong, and that Microsoft think that there is much value in modelling… so we can’t just give up.

Keith walked us through some DSLs (Domain Specific Languages) that are in VisualStudio 2005, showing the higher level abstraction and how it is useful. He told us how if you tool is generates reams of code, you will not succeed. Round-tripping doesn’t work. Microsoft wants “Tripless” (Martin Fowler term).

On a few of the slides for these domains, you would see the header “Aspects”, and under them some cross cutting concerns. I asked Keith about this after his talk, and he said that Microsoft sees a lot of value in modularizing cross cutting concerns, but is scared by code injection. “That is the point!” Microsoft gets AO, and wants to use it in some way in its tools. They need to know that it isn’t about using code-injection, and they are already thinking in the right way. There is such a natural fit for AO in the high level languages that they are building in this modelling framework, and I hope they take a serious closer look at AO and don’t get caught up in some of the implementation details.

May 25

2004 Darwin Awards

Personal No Comments »

I love the Darwin Awards. The 2004 selections have now been made.

Yes, these are (apparently) all true. They are finally out again. It’s an annual honour given to the person who did the gene pool the biggest service by removing themselves from it in the most extraordinarily stupid way. Last year’s winner was the fellow who was killed by a Coke machine which toppled over on top of him as he was attempting to tip a free soda out of it.

It is a scary world!

May 25

“I’m a Java guy in .NET” (Tales from TechEd)

Tech No Comments »

United finally got me my luggage, and I was able to head to my first Microsoft conference, TechEd.

It is a really interesting experience, coming from a very different background (being part of the Java community, and before that: Perl, C++, etc).

My main thoughts have been:

  • Wow it is huge: The show sold out with 11 thousand people
  • Wow it is huge: The rooms are massive
  • Not all developers: Although there are many talks going on at a time, there is only ~one that you would want to go to as an enterprise developer. It is interesting to look and see that there are sessions on the latest Office tools, administrating Windows, and other topics often unrelated to a developers life
  • Females: Maybe partly due to the topic above, there seem to be a lot more females here than at something like JavaOne
  • Java mentions: At every talk that I was at, “Java” was mentioned at each one. If you mention .NET at a Java show, some people go a little crazy. However, it is the fanatics that tend to show this side to them, and the moderates are open on both sides.
  • Interop message: There has definitely been a message of “we are always going to be in a heterogenous environment. Deal with it.
  • Friendly: People have been very friendly, even after they hear that I am an editor of a Java community :)
  • No AOP: It is interesting to see that a lot of the bleeding-edge technologies don’t register quite so much here. This may not be a bad thing!
  • Cabana talks: There are talks in ‘cabana’ areas in a huge room. The talks are interesting in that they are more informal… but one problem is that it is impossible to hear anyone speak (they aren’t mic’d!)
  • Helicopters: This is a San Diego thing I guess… and doesn’t help the above point. A helicopter flies overhead every 2 minutes. I guess the Navy isn’t all over in Iraq?
  • Free Haagen Daas: Say no more

I am having a great time. It is an interesting experience, and I look forward to seeing more of the show. Now I have to see a PDC to compare the “TechEd: hear about the now” to the “PDC: come enjoy the vision”.