Author Archive

If you are doing cross border business in the European Union, then will have to deal with so called “VAT IDs”. I’ve written a small example how to validate VAT ID’s from a Delphi 2010 program. Read the rest of this entry »

Comments View Comments

One of the most used object-oriented patterns is probably this one:

foo := TFoo.create;
try
  //do something with foo
finally
  foo.free;
end;

It basically means, that if you create an instance of some class and if there is no “owner” who takes care of the new instance’s life cycle, then it is your responsibility to destroy the instance again, as soon as you are done with it.

If you don’t care about freeing the objects you created, then you will get “memory leaks”, i.e. you app will use (possibly a lot) more memory as it should.

The technique above is clear and simple, but what if you have more than one object that is needed in a routine? Line them up?

foo := TFoo.create;
bar := TBar.create;
try
  //do something with foo and bar
finally
  foo.free;
  bar.free;
end;

Looks good, and I see this pattern frequently – but hold on! What happens if there is an exception when TBar is created? Right, foo won’t be destroyed in that case. So maybe handle it like this then:

foo := TFoo.create;
try
  bar := TBar.create;
  try
    //do something with foo and bar
  finally
    bar.free;
  end;
finally
  foo.free;
end;

In theory this would be the correct way, and there are a lot of examples that work like that. But look at the code – right: looks really ugly, esp. if we extend that to even more objects being created. Apart from readability there is also some performance hit: every try-frame needs some extra CPU cycles, which may sum up if your routine is time critical already.

My suggestion is this one:

foo := nil;
bar := nil;
try
  foo := TFoo.create;
  bar := TBar.create;
  //do something with foo and bar
finally
  bar.free;
  foo.free;
end;

Now lets discuss some questions about this pattern:

Didn’t we learn, that calls to “Create” have to be made outside the try-finally block?
No, not really. In fact it doesn’t matter where you create an instance of a class. The first example (which is mentioned in many articles) only suggests this, because it’s easy to do so with just one object.

If TBar.create fails, what happens with its bar.free counter part? Wouldn’t it actually be executed on some not “really created” object?
No, in fact bar.free is special method, which can safely be called even on variables pointing to NIL. Free checks if self<>nil and only then the actual destructor is called.

Why did you initialize fo and bar with NIL?
Because otherwise they might have random values. Esp. if they are declared as local variables. And we need NIL initialized variables so that “free” does not call random code in the case of an exception in one of the create calls.

If TBar.create fails with an exception, wouldn’t be there the chance that some address value would have been written to bar already – so that bar.free would be executed on some half initialized instance?
No, if TBar.Create fails with an exception, then the class function “create” would (like any other function) return NO value at all. bar would keep its original value that is.

Comments View Comments

Silverlight is browser plugin-based Microsoft technology for developing applications that run in your Web browser. Silverlight was basically invented to overcome certain limitations that Javascript/HTML/CSS based solutions may have. Microsoft emphasizes esp. on better interactivity, better offline support and better multi media (video streaming that is) experience.

Silverlight has quickly developed from version 1.0 to 4.0, which is the most current version as of today. Version 1.0 was released in September 2007, which means that Microsoft pushed 4 major releases in less than 3 years. Considering that the technology is non-trivial (some sort of .NET integration, derivation of WPF, plugins even for Mac OSX and non Microsoft friendly browsers, VS and Web Expression designers …), Microsoft obviously put in quite some man power to get this done.

Now I look at the recently released Office 2010 version, which also comes with a “Web version” of Office. Via office.live.com Microsoft offers Word, Excel, OneNote and PowerPoint as some sort of light editions of their desktop counter parts.

The layout looks nice, and indeed it feels almost like Office 2010 running on your desktop. The feature set is of course not (yet?) that rich, but for the occasional writer probably all features are there. Here and there it feels a little sluggish, but it works,. Collaboration is way below from what docs.google.com offers, but for a 1.0 version it’s okay.

Now you could have guessed “alright Microsoft’s Office Web team took Silverlight and made this a killer use case for it”, but interestingly if you look under the hood, by examining the HTML source, there appears to be not a single trace of Silverlight. At least I couldn’t find anything but HTML, Javascript and CSS.

This of course leads to the question “Is Silverlight dead?”. If Microsoft does not eat its own food or if the Silverlight team cannot even convince other Microsoft teams to use Silverlight (the SL pieces on the MSDN pages does not really count here imho), does that possibly mean there is something wrong with the technology?

Comments View Comments

Wir, die DelphiExperts gehen mal wieder mit Embarcadero auf DevTracks Reisen und bieten jeweils am Tag danach oder davor einen unserer gewohnt pragmatischen Delphi Workshops an.

Wir werden diesmal gewissermassen das Thema “Sauberkeit am Arbeitsplatz” behandeln, d.h. wir zeigen Ihnen alles zum Thema Sourcecodeverwaltung (Subversion), Debuggen, Fehlereingrenzung und Speicherprobleme. Als besonderes Extra zeigen wir Ihnen, wie man native iPhone/iPad Anwendungen mit einem Delphi Backend verbinden kann.

Die genaue Agenda und Anmeldung findet sich unter www.DelphiExperts.net

Comments View Comments

Daniel and I are happy to announce that our first iPad application is availble since today. Actually it was already available yesterday, but without an iPad it wasn’t that much fun :-)

It’s an iPad only application – it’s a magazine. So it really makes use of the large iPad screen. On the iPhone it just wouldn’t be readable. Daniel and I (and actually Holger assisted us a bit) developed that application for our partner American International Media, who own the magazine. That copmany also owns the USA Sevens Rugby series, which is an interesting Rugby variant: 7 Players per team – 2 * 7 minutes.  From 2016 its gonna be Olympic.

Get the mag at Apple’s AppStore

We considered using Delphi Prism / MonoTouch for this application, but as we know that Apple would come out with a couple of new beta releases of the 3.2 SDK right before the submission deadline, we decided against it, to make sure we were able to deliver. We are working on a DelphiFeeds app though – which will be using Delphi Prism. Stay tuned for that.

Comments View Comments

The ongoing iPhone workshop with Daniel Magin, Evan Doll and my self is apparently going to be a great success. We are basically sold out, the audience is very interested and motivated and we try to get them onto the iPhone development train in our renowned practical style.

We are going to repeat that workshop in Hamburg next week, and there are still a very, very few seats left – so if you got time and want an iPhone development introduction, then come join us in Hamburg on March 22/23.

Sessions are in mixed language mode, i.e. understanding German and English is a requirement. We focus on Xcode and Objective-C, but we also demonstrate MonoTouch / Delphi Prism for Mac briefly.

Event pictures can be found on our partner’s Website: MacWelt.de

Event info and registration for Hamburg can be found here.

Update: Hamburg is sold out too.

Comments View Comments

Wir suchen für einen Kunden im Raum München einen Delphi Entwickler für die Position des Entwicklungsleiters.

Die Postion ist zur Festanstellung ausgeschrieben und es wird eine branchengerechte Bezahlung geboten. Neben Delphikenntnissen und Führungsqualitäten sind Kenntnisse in Betriebswirtschaft wünschenswert.

Bei Interesse ganz unverbindlich per Kontaktformular oder auch über unsere DelphiExperts Seite antworten. Alle Anfragen werden selbstverständlich diskret behandelt.

Comments View Comments

Die Auswertung der Teilnehmer-Feedbacks für unsere letzen beiden DelphiExperts-Veranstaltungen in Berlin und Stuttgart liegt vor. Wir freuen uns über die ausgesprochen positive Resonanz und bedanken uns bei allen Teilnehmern für ihr Interesse!

Die Ergebnisse finden sich hier: www.delphiexperts.net/events

Comments View Comments

I hit "Yes" on the dialog below, which basically says:

"Are you sure you want to delete the Internet?".

Please don’t bash me if you cannot get to the Internet anymore – I am working on restoring a backup :-)

Internet Deleted

Comments View Comments

English: This article provides some preview information about Delpi/Prism/Pascal on the Mac compiling for the iPhone. English content is available at Daniels Blog.

Native iPhone Anwendungsentwicklung bedeutet normalerweise das Auseinandersetzen mit Objective C, der Haus- und Hof-Sprache von Apple. Man bekommt, nachdem man sich als Entwickler bei Apple registriert hat, die komplette X-Code IDE inklusiver aller Werkzeuge praktisch kostenlos zur Verfügung gestellt.

Read the rest of this entry »

Comments View Comments

CodeGear Technology Partner