Lizard

It’s been almost a year since the military overthrew Thailand’s elected government. I haven’t blogged about Thai politics since, simply because there isn’t really anything to report. The civilian government appointed by the military has managed to keep the country plodding along nicely. In the mean time, a new constitution was drafted and a referendum was held on August 19th.
Only 57% of registered voters bothered to show up. 58% ticked the box “I like what I see”, while 42% ticked the “I don’t like what I see” box.
Though that means the constitution was approved, the margin is obviously very thin. And, people voting “yes” don’t necessarily agree with the constitution or the way it was drafted. They simply want to country to move ahead with the elections scheduled for mid-December. In Thailands Northeastern region, which is the most populated and also the poorest, 63% of the voters rejected the constitution. It’s no surprise that the military are more than a little worried about their public image.
The army chief, who is close to his retirement, has stated that his successor should make PR a top priority. My idea is that staying out of politics would be a good start. Unfortunately, that doesn’t seem very likely in the near term, as the new constitution gives more power to the military and to bureaucrats at the expense of elected representatives. However, constitutions are hardly written in stone in this part of the world. Most political parties encouraged their voters to accept the draft constitution, not because they like it, but because it clears the impasse allowing new elections. Once a new elected government is in place, it can work on amending the constitution in a more democratic process.
Other than the odd political situation, it’s very much business as usual in Thailand. Phuket, one of Thailand’s main tourist destinations, is enjoying an unusually strong low season (May to October). It’s the first time after the December 2004 tsunami that tourists are back in full force. If the trend continues into the high season, you might not want to wait too long if you were planning to book a trip to escape the cold winter back home. There hasn’t been any noteworthy political unrest since the coup last year, and there’s unlikely to be any going forward.
My Delphi 2007 for Win32 post from last February has been attracting a lot of comments. Whaddayaknow! Searching for Delphi 2007 on Google lists that post as the 4th result.
The initial release of Delphi 2007 was a bit marred by new bugs in the Forms.pas unit. These were caused by code changes needed to support the Application.MainFormOnTaskBar property. If you set this to True before you call Application.Initialize, then your application will associate the main form’s Handle with the taskbar button rather than Application.Handle. This should do away with longstanding issues like Tile Horizontally leaving a gap the size of one phantom window, or your application appearing twice in certain Alt-Tab replacements.
Fortunately, Delphi 2007 update 1 is out already, and fixes the Forms.pas bugs. If you don’t make any change to your code, it’ll work the same when compiled with Delphi 2007 as with previous versions.
If you’re still using Delphi 7 or earlier, Delphi 2007 is a must have upgrade. You can buy the Delphi for Win32 personality separately if that’s all you need (unlike Delphi 2005 and 2006 which bundled all personalities). Don’t worry about the impending “Highlander” release. Highlander will have no new features on the Win32 side. Highlander updates the Delphi for .NET personality. If you buy the Highlander studio product (all personalities), you’ll get the same Delphi 2007 for Win32 and C++Builder 2007 that are already available separately, plus the new version of Delphi for .NET.
The main reason to upgrade is that the IDE now runs without issue on Vista. Though you may not use Vista as your primary development platform (I use XP), you definitely want to be testing all your products on Vista. And that’s much easier if you can debug right within the IDE.
CodeGear has published some articles on their site explaining important new features available in Delphi 2007, but not in Delphi 7. I’ll reiterate that all of this applies to good old Win32 development. The new IDE requires the .NET framework, but your applications definitely won’t.
Language and compiler features since Delphi 7
The most popular language feature is probably the new “for..in” syntax. E.g. to iterate over all stings in a list, you can write “for S in MyList do Something(S);”. This is like the foreach operator in other languages, without introducing a new keyword.
Operator overloading allows you use any class in an expression using Delphi’s standard operators. E.g. if A, B and C are types of TMatrix, you could do matrix addition simply with C := A + B. All you need to do is to add one class function to the TMatrix type that takes two parameters and returns the result of the addition. You’ll use the new “operator” keyword instead of “function”, and give the method a predetermined name like “Add” for the + operator.
Class helpers were first introduced in Delphi 8 (the maligned .NET-only release). A class helper essentially allows you to add methods to an existing class, without creating a new class as descending from the original class would do. If the exising class has descendants, the helper methods will also be available in the descendants. E.g. if you create a class helper for TStrings, then all its descendants like TStringList and TComboBoxItems will also have the helper methods. This is a bit of a hack, actually. The only situation in which you should use this is when you really can’t modify the original class directly, e.g. because you don’t have the source code. That’s exactly the situation Borland faced with the classes provided by the .NET framework. No source for Borland to modify. Class helpers are now also available in the Win32 personality.
A lot of class design features from .NET were added to Delphi for .NET and now to Delphi for Win32 as well. These include “strict private” and “strict protected”, for design purists who believe that friends (classes in the same unit) shouldn’t touch each other’s private members. Classes can now be declared abstract in their entirity. Classes can be marked sealed, and methods marked final, preventing descendants and overridden methods. Classes can now contain class constants, class types (including nested classes), class variables and class properties. All of these apply to the class as a whole rather than each instance. In C# parlance these are “static” members.
New VCL features since Delphi 7
Starting with Delphi 2007, VCL applications are themed by default, so they look great on XP and Vista. The TForm.GlassFrame property now allows your forms to use the Vista Aero glassing effect.
New VCL components for new Vista features include TTaskDialog, TFileOpenDialog and TFileSaveDialog.
TFlowPanel and TGridPanel are two new VCL components for automatic layout management. The new Margin and Padding properties work like margin and padding in cascading style sheets (CSS) on the web when you set AlignWithMargins to True and use the Align property to align the control. If you’re tired of setting pixel positions and sizes on all your controls, these new components and properties will save your day.
The TCategoryButtons and TButtonGroup components allow you to easily implement a control like the new component palette in the IDE. And if you’re not using one of the heaps of freeware TTrayIcon components, Delphi finally includes one of its own.
New IDE features since Delphi 7
Actually, this should read: “totally new IDE since Delphi 7″. The first time you try the new IDE, it’ll come across as a big slow beast. But it’ll quickly grow on you when you discover all the new features. The article linked above has a bunch of screen shots.
Only two items in that article don’t have screen shots. This includes the “enhanced debugging features” item. This item alone is well worth the upgrade. E.g. the local variables view can now show local variables for any function on the call stack. All variable views, including local variables, watches, and even the tooltips can now show all fields in objects when you click the + to expand the object’s node. If some of those fields are objects, those can be expanded too. This is tremendously useful. Delphi 7 would only show a useless pointer address, requiring you to manually add watches to see individual object fields.
If you’re interested enough in Delphi 2007 to make it all the way to the bottom of this long article, you know you need it! Unless you always write bug-free code, those debugging features alone are well worth the few hundred dollars for the upgrade. Remember: you get the Delphi 2007 upgrade discount no matter which previous version you have, even if that’s Delphi 1.
It’s Not Carpal Tunnel Syndrome by Suparna Damany and Jack Bellis is a must-read for anybody who spends more than a few hours a day. That’s probably everybody reading this geeky blog!
The title refers to the fact that Repetitive Stress Injury (RSI) is often misdiagnosed as Carpal Tunnel Syndrome (CTS). CTS occurs when a nerve that controls finger motion becomes trapped or restricted in its movement though your wrist. My 93-year-old grandmother who never touched a computer or typewriter in her whole life was treated for CTS over a decade ago. While it’s certainly possible for a PC junkie to suffer from CTS, it’s far more likely his wrist and nerve problems are a symptom of RSI rather than a direct problem in themselves.
Whenever your fingers hit the keyboard or your arm reaches for the mouse, you’re applying a small amount of stress to your upper limbs. If you do that for long hours throughout the years, those repeated tiny bits of stress can wear you out, resulting in a case of RSI.
This book explains the nerves and other body building blocks that suffer while you’re slaving away at the keyboard. The language used is very easy to read by any PC user. The few medical terms that are used are clearly explained.
The second half of the book explains what you can do to prevent and/or cure RSI. You won’t find any miracle potions or step by step guides with guaranteed results. Instead, based on the knowledge of how people get RSI in the first place, you’ll find plenty of tips and suggestions of changes you can make to your working habits and equipment, and how those will affect your body. Since everybody’s different, what works for one person doesn’t necessarily work for somebody else. That’s what makes this book so useful: by learning about the innards of your upper limbs, you can make more educated choices, and ask more detailed questions when you seek medical advice.
The best time to read this book is when you don’t have any RSI symptoms yet. It’s your best bet of never getting any.