Archive for the ‘Misc’ Category

From the Horses Mouth

That is Jonas’s phrase not mine.

Anyway, Jonas is blogging! Yay!

I don’t even mind that he pointed out all my mistakes. If it keeps him writing these sorts of useful blogs, I’m happy to keep making mistakes 🙂

Japan : Delphi 2005 vs Typhoon Tokage

I arrived in Tokyo this week to do some early briefings around Delphi 2005 (aka Diamondback), the same week that Typhoon Tokage arrived. I spent a couple of days briefing journalists from the major Developer magazines in Japan, but given that the launch of the Japanese version of Delphi 2005 lags behind the English edition by a little while, we chose to do the public events a little differently. As Arisawa-san pointed out in his blog, Japan are holding full launch events later in November, however this time we invited select members of the Delphi community in for a briefing. These are guys who run User Groups, run online Forums, publish Japanese Delphi magazines, etc. In other words, the kind of enthusiastic community members that Borland is blessed with all around the world, and this was, we thought, a small way we could try and repay that enthusiasm.

We had scheduled this event for Wednesday night, which it turns out was the same time when Tokage was due to hit Tokyo. As cool as we think Delphi 2005 is, we thought that maybe people may not want to come out to a Delphi event just as a 800km-wide Typhoon descended directly on Tokyo, we contacted the invited people and offered to run it on Thursday night instead. Some took us up on the offer, but amazingly, a surprising number were willing to brave the Typhoon in order to get a first look at Delphi 2005 in Japan!

So, if these guys are willing to risk it, who am I to say no, so as rain flew horizontally past the window, flood levels rose, and much destruction was wrought elsewhere in Tokyo, we had a group of guys sitting watching my demos and getting very excited about what they were seeing. To say it was surreal is an understatement. These guys are so hardcore! We’ll run it again tonight, but so far this has been the most memorable part of the Delphi 2005 launch. Singapore, Malaysia, Thailand and Korea in the next few weeks will have to raise the bar in order to top that!

ECO : OCLPSHandle

So far in my ECO examples, I’ve been ignoring the issue of performance. I’ve been behaving as if my application will perform identically whether I have 10 objects or 1,000,000 objects. Obviously, this is absurd, so I want to start dealing with this issue. There are many things you can do to control the performance of your ECO app, and this first article will look at one of them, specifically the OCLPSHandle.

Look at the following OCL for example

Person.allInstances->select(Age < 18)

Hopefully by now you recognise that this OCL will return a collection of all Person objects that have the value of their Age attribute less than 18. If we use an ExpressionHandle to execute this OCL, as we have been in all our examples so far, a few things could happen. Firstly, let’s assume that our ECOSpace is empty, so any Person object we wish to access will need to be loaded from the database (we’ll deal later with the case where our ECOSpace is not empty).

So, how can we see what happens when we request this OCL to be executed? There are a couple of tools that I find useful in this type of situation. One is some sort of SQL monitor, so that I can view the actual SQL being executed by the ECO Framework. The other is the OptimizeIt Profiler for .NET, a CPU and Memory profiler that ships with the Architect edition of Delphi and C#Builder. The Memory Profiler in OptimizeIt allows me to peer inside my ECOSpace and see exactly what objects are in memory.

Back to our example, however. The ExpressionHandle behavior is that the select filter above will be executed by the ECOSpace. If we look at the contents of our ECOSpace before executing this OCL in an ExpressionHandle we can see that there are no Person objects instantiated (note the filter I have placed in OptimizeIt, allowing me to only view my domain objects).

When I execute this OCL using an ExpressionHandle, a number of SQL statements are executed. My example is using SQL Server, and in this case, firstly ECO executes this:

SELECT BOLD_ID, BOLD_TYPE FROM Person

Then the BOLD_ID’s returned from this statement are used in the following SQL, to actually return the complete objects:

SELECT BOLD_ID, BOLD_TYPE, Firstname, Lastname, Age FROM Person WHERE BOLD_ID IN (…)

where the list of BOLD_ID’s are inserted between the braces after the IN statement.

Think about this for a moment. This means that all my Person objects will be loaded from my database into my ECOSpace, then the ECOSpace will filter out the correct Person objects and return my collection. While this might be fine for 9 objects as I have, what if I have 10,000 objects, or 100,000, or 1,000,000? This will rapidly become a problem. Just to be sure, this screenshot from OptimizeIt shows that the ECOSpace after this statement is executed holds 9 Person objects, even though my Grid only displays the 2 that match my select statement.

So, how can we exercise some control over this? Well, this is where you can use a component called OCLPSHandle. The PS in the name stands for Persistent Store, because this component will attempt to convert the OCL into a SQL Statement so that the filtering in this case will be executed by the backend database rather than the ECOSpace. So, the exact same OCL as above, but loaded into an OCLPSHandle rather than an ExpressionHandle, results in the following SQL being executed:

SELECT BOLD_ID FROM Person WHERE (Age < 18)

Note the very important WHERE clause, which means the database will do the heavy lifting for us and only return the records that match the OCL filter. ECO can then request the full data only for the required objects. Again, OptimizeIt shows us that after this OCL is executed, only the 2 matching objects exist in our ECOSpace.

And note the end result in our Grid is the same:

Not only is this much more efficient over the network and more efficient in terms of memory, it also executes a lot faster. There are a couple of downsides (c’mon, nothing comes for free). Whereas an ExpressionHandle will execute its OCL automatically, we need to call the OCLPSHandle.Execute method in order for it to execute the OCL and return the result. Still, a small price to pay for such improved performance.

Secondly, the OCLPSHandle, by its very nature, can only return objects that are stored in the database. If there was a Person object in memory that matched my OCL filter, but that had not yet been persisted to the database, the OCLPSHandle would not by default include that in the resulting collection. This can be worked around of course, and Christophe Floury in his excellent "Unleashing Enterprise Models" (C#Builder version / Delphi version) whitepapers shows example source for this very issue. Basically he uses the OCLPSHandle as above, then interrogates the ECOSpace and adds any Person objects to the resulting collection that have not yet been saved and that match the filter.

So, we can now deal much more effectively with large numbers of objects. There is more we can do to tweak ECO’s performance, but that will have to wait for a future article.

Technorati Tags: ,,

Leaving on a Jet Plane, Don’t know when I’ll be back again…

My home for the next month or two is going to be somewhere in Qantas Economy Class. Starting next week we’re kicking off a whole bunch of Diamondback Sneak Peeks around Asia Pacific. I’m both excited about it (I’m really looking forward to the reaction from the audience to Diamondback) and dreading it (I’m a fairly grumpy traveller) at the same time.

So the next two weeks I’m doing the rounds of Australia, covering Sydney, Canberra, Melbourne, Brisbane, Adelaide and Perth. More details here

After that it’s Japan, Malaysia, Singapore, Thailand, Korea and after that it gets kinda blurry. China and Taiwan will be handled by the extraordinary Gordon Li, and New Zealand has already been covered by the equally extraordinary Richard Vowles. I’ll try and post photos as I go around.

I think I get home before Christmas.

Upside is I write most of my ECO blog articles on flights, so no excuses over the next couple of months.

BCN2Outlook

Sorry to be so late in posting this. A couple of people have asked me about this old utility leading up to this Borcon, but what with trips and catching up with life when I get home, I haven’t got around to uploading it before now. Here’s the description from years ago when I first released it:

The Borcon US website allows you to select sessions you are interested in attending and then download a BCN file. They also provide tools to sync this BCN file with your Palm Calendar.

This is all well and good, except for those of us who don’t use a Palm!

BCN2Outlook is a simple tool we’ve developed to allow you to sync your BCN file with Outlook. Once it’s in Outlook, you should be able to sync from your Outlook Calendar to whatever flavour PDA you use, using its standard Outlook sync. We’ve tested this with Outlook 97 and 2000, and PocketPC ActiveSync, however it should work with other versions of Outlook.

BCN2Outlook is offered free to other Borcon attendees

I haven’t tested it this year, but I imagine it should still work. Post-Borcon I’ll dig out the source for it and post that as well.

Hama-rikyu, Japan




© 2004, Malcolm Groves

 

I spent a very lazy and indulgent afternoon at Hama-rikyu today. Hama-rikyu was the family garden of the Tokugawa Shogun, and sprawls over many acres beside Tokyo Harbour. I’ve meant to visit these gardens on my last few trips, but this is the first time for awhile that I’ve had the weekend free in Tokyo.

Unfortunately, it rained constantly (Typhoon Chaba is on its way to Japan now that it has finished with Taiwan), so it wasn’t the best weather for photography, but it did mean I had the place pretty much to myself. I only saw two people in 4 hours, which is a rare occurence in Tokyo. One was the Head Caretaker of the gardens, who charmingly came out to thank me for visiting in spite of the rain, and the other was the lady who served me at the tea house.

Despite the rain, a very relaxing afternoon. I’ll post more pictures, but many of them didn’t turn out very well due to the light.

 




© 2004, Malcolm Groves