Rad & Dot Net - Digital Warrior

Assorted ramblings (and vents!!) from a techie on the sunny shores of Kenya, East Africa

Wednesday, January 26, 2005

Delphi 2005

Installed all 900MB of Delphi 2005 yesterday. It apparently can write Win32 apps, Delphi.NET apps and C# apps. Watch this space!

Friday, January 21, 2005

Africa Dot Net

Make sure you come for the AfricaDotNet user group meeting at the Microsoft offices this Saturday (22 January)

Friday, January 14, 2005

RSS Readers

In the search for a good RSS reader i've run through a number and dismissed them all. Basically in my opinion these are the best:

- FeedDemon - very impressive and comprehensive, with a search engine and a newspaper view. Very Outlook like interface and very intuitive. Problem is it ain't free!

- RSS Bandit - Next best thing, also with the all important newspaper view. You can also get the source code and tinker to your satisfaction

- RSS Owl - the newspaper view requires additional keystrokes but also pretty functional

Honourable mention also goes to Omea Reader. Looks pretty good but still has the look and behaviour of a Version 1 type thing.

Yes yes, i've also tried out SharpReader, RSS Reader, FeedReader, NewsDesk and a host of other and found them wanting

Monday, January 10, 2005

Undeletable Files?

I deleted a bunch of directories on my WinXP machine and strangely enough even after emptying the recycle bin the available disk space did not change. I had turned off that system restore nonsense a long time ago, and emptied the folders again just to be sure but no cigar. 300MB that should have been freed from deleting the folders was not freed.

The answer came to me while I was writing a small utility to backup my current projects, and in the course of it's activities it built the directory structure in a treeview. There, to my amazement, was a bunch of folders in the recycler folder. (Note that the recycle bin shows empty!). Opening these folders (which had lengthy cryptic names indeed) revealed the folders I had just deleted. Writing code to nuke these was but a few seconds work.

However an easier option is there - using Nero Burning ROM. Open the explorer and navigate to Recycler. Nero will show you everything that is in in there and will let you delete them. Oddly enough, they will go to the recycle bin and appear there properly, and then you can empty the bin

Friday, January 07, 2005

VB.N(OT) (Y)ET?

Accoring to some interesting statistics, VB 6 Developers are deeply in love with their VB. 80% prefer VB 6 as opposed to 17% on VB.NET. 2% are still sticking to VB 5.

The complete survey is at Visual Expert

Of course you know what they say about statistics ....

Python Update

My experiment with Python is moving along excellently. Now I know where the inspiration for the C# foreach construct came from.

The use of indentation to delimit construct scope is also sheer genius. In one stroke the application is easy to read, and you are forced to be organized when the logic is complex for instance with nested loops, if statements and so on.

Another interesting thing is that everything is an object, including functions! Whoa!

Python can import a particular class or function from a module (package / namespace). So from the sys (system) module you can import just the argv (arguments) object. This may not be a big deal for desktop apps but when someone gets round to porting python for use on a phone, the implications will be great.

Also, if python also straddles a fine line between being interpreted and being compiled. In cases where you import from another file or class, compiled code is generated to enhance performance. The kicker thing is this compiled code is cross platform

You can also delete objects from namespaces when you're done with them.

And oh, python is nothing to do with snakes but rather it was named after Monty Python.

However theres some upcoming development going under the delicious name of Boa Constructor. This is an interesting project and as far as I can tell it's a complete IDE for Python written in python.

definitely worth investigation!

As for ability, someone has written a P2P type application in TinyP2P in 15 Lines of Code. Yikes!

Excel Dilemmas

Tinkering around with Excel and VBA has led me to some pretty interesting discoveries.

If you enter the following formula in a cell

-4^4

It returns the value 254, which is correct as far as elementary mathematics is concerned. -4 squared is +254

However the same expression if executed through code, either VB proper or C# or even VBA, the exact same expression yields -254

And if you think about it, the second expression is also correct insofar as most languages have the precedence of power as higher than that of the negative.

Which is to say if you drive Excel using VBA and calculate cell values using both VBA and Excel forumulae, you are in for the high jump.

The dilemma is that changing this behaviour in Excel could precipitate riots in the the current user base of Excel which runs in the millions if not billions who will probably not take kindly to having to change their worksheets and macros. Any attempts to do this will result in the same gymnastics along the lines of the different base dates (January 1, 1900 and January 2, 1904) that Excel supports. Talk about being between a rock and a hard place!

Wednesday, January 05, 2005

Java.NET?

I wonder ... I wager it is just a matter of time before a compiler that can take java source code and spit out MSIL will make an appearance, as is one that will take .NET source code and spit out java bytecode.

Better yet, a cross compiler that can take MSIL and spit out java bytecode (cutting out the horrendous task for catering for VB.NET. J#, C#, Cobol.NET, etc, and going right to a unified MSIL), and vice versa. This will be a killer tool that will enable you to use a java class from a .NET app and a .NET class from a java app. It's bound to be quite an awesome beast because it will have to cater for features that are in one language but not the other and substitute viable workarounds (particularly the totally different event handling mechanisms). There are huge implications to something like this, but if man can go to the moon, this is a distinct possibility.

Python

Developers all over the globe have almost militant attachment to their tools of choice (self included) and are always willing and ready to take pot shots at other tools. In this regard you can find almost vitriolic opposition to Java, C#, VB, Delphi etc by proponents of some tool or the other

However the strange thing is that almost everyone thinks highly of Python. In fact, if you know Python you are halfway to getting a job at Google

There are also a couple of interesting projects in various states of completion, the most intriguing being JPython (think Python for Java, able to use java classes and generate bytecode) and Python.NET (same thing, but for .NET).

I'm playing around with it right now and all I can say it's pretty interesting. The syntax is almost english like and there are no irritating END IFS, END DO, BEGIN, etc -- all that is done by indentation!

Tuesday, January 04, 2005

Visual Basic.NET

A project I'm enhancing, done in VB.NET brought back all the memories, good and bad, of VB. Circa 2000 AD I was an ardent fan on VB until I did a project that required intelligent clients and a central server. Reporting was done through Crystal Reports. The hair I ripped from the roots trying to figure out why the exact same installation failed to work on two machines with identical specifications is one of my starkest memories.

Another is of why the Crystal Reports DLLs refused to register, either through the installation or regsvr.

Yet another is the 7,898,909 versions of the VB runtime that I found on the assorted machines, some of which refused to run the application, others which swiftly and ruthlessly decided that components like report viewers, common dialogs, etc. were a mistake on my part, and what I had actually wanted were picture boxes, proceeding then to convert them accordingly.

The wild eyed look in my eye prompted a chap of mine, Tim, to again demonstrate the virtues of Borland Delphi. In fact on that note we used to have furious debates on the merits and demerits of VB and Delphi, but on that particular day my spirit had been crushed after an entire week trying to get an application installed and running on 12 clients.

After a half hour tour of Delphi, suffice it to say that particular project was the last time I laid eyes on VB. I unistalled VB, installed Delphi and never looked back. Of course the Visual Studio 2002 beta appeared soon after and I have been swimming in two pools ever since :)

Until now of course. The DLL woes are gone, and there is finally structured exception handling, and object orientation. However I cannot help but get the felling that it has been 'hacked' for lack of a better word to get it CLS compliant. And even before you flame me 'hacked' is not necessarily a bad thing! The festival of keywords is impressive, reminding me of my days as an unwilling schoolboy learning the periodic table but on the bright side the concepts of OOP are refreshed every time you type MustInherit.

But so far all i can say is that compared to it's predecessor, VB.NET is the Homo Sapiens to VB6's amoeba

Gripes:

1) The sheer amount of typing to be done!

War And Peace

Public ReadOnly Property ID() As String

    Get

            Return 
m_ID

    
End Get

End Property


Puss In Boots

public string 
ID{
 
    get{return m_ID;}

}




2) The convoluted way of coding for the events. There must be a less ridiculous way than those two combo boxes at the top of the code view! Since imitation is the sincerest form of flattery it would be nice for the C# property grid with it's events pane migrated.

Also, is there a way to get Enter to do the same work as Tab? I've not had time to explore too much but my heavy C# bias and usage has accustomed me to use that key to autocomplete. It must be an option buried somewhere

Monday, January 03, 2005

SharpDevelop

Been playing around with SharpDevelop 1.02 and from what I can see it's REALLY COOL! They've clearly borrowed ideas heavily from VS but hey - flattery is the sincerest form of imitation! The built in Unit Testing, disassembly viewer and Profiler are a great idea. Similar results, at least as far as Unit Testing are concerned can be obtained from installing TestDriven.NET if you use any Visual Studio (including Whidbey)

It has a fully featured forms designer, caters for C# and VB.NET, as well as C++ and ILASM. Hats off to you if you code in the latter.

I distinctly recall that some early builds had Java support but this seems to have fallen by the wayside. Sense always tends to prevail. Even Borland, who do some amazing things with their editors have not attempted an IDE that caters fully for both Java and any of their other development platforms (Delphi, C++ Builder, etc). But that said and done the specs for Delphi 2005 are impressive. And were anyone to pull it off it would be implemented pretty much as two separate projects. This would save on developers' pulled hair and smashed keyboards, symptoms of frustrated developers.

It also has neat stuff like a colour picker you can use in the code view. So if you don't know the difference between Airforce, navy and marine blue (97% of the male species) you can simply select the colour you want and the code is dumped for you in the editor.

Maybe it's just me but I can't seem to find all those things that I'm used to like breakpoints and debug windows and output windows. Which makes me wonder what

Trace.WriteLine()

will do!

ASP.NET developers are left in the cold, without so much as a match. Web Matrix is pretty good but if you are used to the CodeBehind way of doing things, you're buggered.

Otherwise it's pretty able and when it comes to value for money (FREE!!, including source code) it rules. Try it out Sharp Develop And in fact on that note I see a new build is available.....

Null Dates & Typed Datasets

Making heavy use of the typed dataset generally works 99.99% of the time, but things get unglued when you run into a situation where you define one that has DateTime property that you want to be nullable.

Setting minOccurs to 0 is fine, but the instant you define the null value as null, it refuses to compile. If you leave it as blank it will compile, but if you fill the dataset and the DateTime field happens to be null, a runtime error is thrown!

Hmmm.

So as a workaround, you have to put something in the field to make sure everything runs. My workaround is to use a certain date to represent a null value, so I happily did this:

ProductData.ProductRow row = New.ProductData.ProductRow();

//not using SelectedValue becuase you might run into a 1.0 runtime!

row.ProductID = int.Parse(cbProductID.SelectedItem.Value);

row.Name = Utils.ParseText(txtName.Text);

row.Description = Utils.ParseText(txtDescription.Text);

if
(txtStartdate.Text == "")

row.Startdate
= DateTime.Parse(Utils.ParseDate(txtStartdate.Text));

else

row.Startdate = DateTime.MinValue

row.EndDate
= DateTime.Parse( Utils.ParseText(txtEndDate.Text))



Problem with this is that SQL Server and .NET do not agree on what the smallest date should be, and so it throws a runtime error, since the .NET minimum date is too small to be stored in SQL server. As far as .NET is concerned, the smallest date value is just about 0AD (Which makes storage of Roman Census data a bit of a problem! Is this backward compatibility with the abacus or what?!!). As far as SQL server is concerned the smallest date value possible is about 1st january 1753.

So to work around this little snafu instead of DateTime.MinValue create a new date as above.

Now the only thing left is to modify the UI code to behave itself when presented with this particular date, since it strictly means there is no data. A quick and dirty workaround is to handle the OnDataBinding method, and reset the date to the current date.

By the way, is it just me or is the DatePicker's method of handling a lack of data too awkward? That funny little checkbox, as far as I'm concerned is not intuitive at all! If it is checked does it mean that it is null or that it has data? And the reason that our OnDataBinding override is set to the current date is to spare the more arthritic among us from clicking themselves into the grave shifting the date from when we begun celebrating New Year's Day to the current date

Lethargy 2003

Yup. Office 2003 also insists on spelling Mombasa as Mombassa. But look on the bright side. At least there's consistency, which is something WordPerfect and Lotus ought to investigate!

Sunday, January 02, 2005

More on Dictionaries

And more on that note, it cannot be too much of an effort for someone to sit down, collate a list of the most known of Kenya's cities (Nairobi, Nakuru, Mombasa), some key personalities (Kenyatta, Koinange, Kimathi), some landmarks (Tsavo, Mara), a date format of d MM yyyy, a currency symbol of Kshs, throw in most of the UK dictionary and bits of the US (our English is mostly the Queen's English) and package the lot as English (Kenya).

This way we can stop being patronized by being forced to choose between English (UK) and English (US) and having to spend most of our time removing dollar and pound signs and being forced to write extra code to format currencies and dates!

Lethargy 97, 2000, XP, etc

Those of us who are Kenyans I feel sure feel the same sense of outrage when after working on an Office Document and hitting F7, the spell checker helpfully offers Mombassa as an alternative for the accurate spelling, Mombasa

I can't offhand recall if this same ridiculous behaviour manifests in Office 2003 but am willing to take wagers that it does! I'll check as soon as I'm out of this cybercafe whose machines seem to be running Windows 98 Build 1 and office 97

And on that note when it comes to spelling dictionaries we have English (Australian), English (New Zealand), English (UK), English (US), English (South Africa), English (Zimbabwe). Strangely there is no English (Kenya).

Oh, and did I mention that Microsoft have regional office in Kenya?!!

Bonus!
There is a certain road in the quiet suburbs of Upper Hill called Matumbato Road. Type that in Word, spell check and marvel at the suggestions :)