knoppix saves the day

Knoppix has saved my machine again. I have suffered a minor hard drive failure, which left windows unable to boot. Given that I am unwilling to reformat my C: drive given that knoppix can read it, I have had a very slow windows 2000 reinstall – it insists on checking bad drives at reboot. Windows 2000 does so love it’s reboots. Knoppix on the other hand reboots in a min or less and can read all of the data drives. I was impressed that it had sound support from startup and was quite haapy about me plugging in USB devices. I am just finishing the restore of my emails from a drive windows describes as corrupt.

Thoughts on Programming Tools for Non-Programmers

There has been a trend in recent years to reduce the complexity of software development so that non-programmers can acheive useful results. However by the time the non-programmer has completed a non-trivial project they are oftern well on their way towards becoming a programmer. The drawback is that they oftern fail to learn useful lessons and skills (version control, error handling, the once-and-once-only rule). In my experience this is highly prevalent in the VB world. A end-user that knows some VBA puts together a VB.NET application, this grows to be a critical application…

AJAX and PHP

Here is a link to an article on AJAX and PHP.
This is intended to make websites far more dynamic.

In case anyone is wondering why I am using PHP it is because I bought a domain and hosting for £30 for two years. The site advertised Pythin support that I only found out was disabled after I had the domain. The remaining options were Perl or PHP. I found the PHP to not be too painful to use. The site is strictly of local area interest so does not get quite the load that would cause trouble.

What a Web Service contract requires

A comment on one of my earlier posts lead me to think of a feature that is missing from web services. The whole point of using web services is to decouple links between products so that it comes down to a service agreement. I think that these agreements should have a defind duration. This should be of the form “I promise to keep this service available for 3 years and I will update my future intentions after 2 years”. This could permit a web service to evolve over time without breaking the contract.

COM used to have immutable contracts – although these were occasionly broken ( OLE-DB has a great feature that breaks the IUnknown contract – the behaviour of IUnknown on a provider varies depending upon whether the connection is connected).

This would require some extensions to the basic infrastructure but would save a lot of trouble in the future. This would prevent a system being built with a dependance upon somrthing that is just due to expire.

Cognotive Distance

A discussion in this dot net rocks show explained why an experienced C++ devloper would chose to use VB.NET over C#. The two languages are of equivalent expressiveness but have slightly different biases. VB.NET is better for dealing with variants and default parameters while C# has unmanaged code support.

Kate’s argument was that C# was too close to C++ to make freely jumping between them difficult and error prone this made VB.NET a more natural choice. I have had similar experiences. Currently I am working in Delphi, SQL and C#.

I find that keeping the SQL in strict upper case allows me the seperation so that I don’t find myself adding “then” to the end of my if statements. This allows me to keep a Cognative Distance between the two languages. Since Delphi and C# have a suitable distance between them (begin end vs {} ) I generally don’t have a problem switching..

The major gotcha that I have between Delphi and C# is the calling of a method with an empty parameter list. In Delphi you can call foo; where C# requires foo();

C# reserves foo for referencing the method itself.

The other niggle that I have with C# is the casting syntax.

In Delphi if I wanted to cast a class to a specific descendant and then use a method exclusive to that type I would use:

TChild(aParent).ChildMethod;

C# would require:

((TChild)aParent).ChildMethod();

which has slighly too many brackets for my taste.
I know this was implemented for the C and Java developers but since one of the aims of C# was to correct the mistakes of the C and C++ world this could have been improved.

 

Greasemonkey documentation

Greasemonkey is a Firefox extension that allows the reconfiguration of websites.

The documentation can be found here.

The general idea is that if you find a site that does not work how you want it to you can rescript it to avoid annoyances. I will be experimenting with this and will record my progress.

MSMQ Samples

Here is a sample of  using MSMQ

The example in .NET Framework essentials does not seem to work.

This is still a simpliefied version, not actually handling timeouts very cleanly.

//This is Enque:
// Enque.cs
using System;
using System.Messaging;

namespace EnqueSample
{
    [Serializable]public struct Customer
    {
        public string Last;
        public string First;
    }
    class EnqueSample
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            try
            {
                string path = “.\\PRIVATE$\\NFE_queue”;
                if (!MessageQueue.Exists(path))
                {
                    MessageQueue.Create(path);
                }

                MessageQueue q = new MessageQueue(path);

                Customer c = new Customer();
                c.Last = “Eyre”;
                c.First = “Chris”;

                q.Send(c);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
    }
}
// Deque
// Deque.cs
using System;
using System.Messaging;

namespace Dequeue
{
    [Serializable]public struct Customer
    {
        public string Last;
        public string First;
    }
   
     class Dequeue
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            try
            {
                string strQueuePath = “.\\PRIVATE$\\NFE_queue”;

                if (!MessageQueue.Exists(strQueuePath))
                {
                    throw new Exception(strQueuePath + ” does’nt exist”);
                }
                MessageQueue q = new MessageQueue(strQueuePath);

                Type[] t = {typeof(Customer)};
                ((XmlMessageFormatter)q.Formatter).TargetTypes = t;

                Message m = q.Receive(new TimeSpan(0,0,5));

                Customer c = (Customer) m.Body;

                Console.WriteLine(“Customer: {0} {1}”, c.First, c.Last);

            }
            catch(Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            System.Console.ReadLine();
        }
    }
}