XP Values, Practices and Principles

Here are the XP

Values:

  • Communication (possibly Visibility)
  • Simplicity
  • Feedback (formerly Testing)
  • Courage (formerly Aggressiveness) (See: XpCourageValue)
  • Respect

Practices:

Principles

Fundamental Principles:

  • Rapid Feedback
  • Assume Simplicity
  • Incremental Change
  • Embracing Change
  • Quality Work

Further Principles:

  • Teach Learning
  • Small Initial Investment
  • Play to Win
  • Concrete Experiments
  • Open, honest Communication
  • Work with people’s instincts – not against them
  • Accepted Responsibility
  • Local Adaptation
  • Travel Light
  • Honest Measurement

Why so brittle?

C# has inherited a brittleness from the Visual C++ world.

By default an unhandled exception in any application will kill an application and return an exception trace even in a windows form.

In Delphi in a forms application the exception shows as a message box.

The assumption in Visual C++ and then C# is that an unhandled exception could result in data corruption so you must shut down now. The assumption in delphi is that some error has occoured.

It is possible to add simple code to emulate the Delphi behavior

// Add the following to your uses clause:
using System.Threading;

//In your main method before run implement the following

Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(new CustomExceptionHandler().OnThreadException);

// Here is the exception handler (in production code use something more elegant, but for development this is fine:

        // Creates a class to handle the exception event.
        internal class CustomExceptionHandler
        {
 
            //Handles the exception event
            public void OnThreadException(object sender, ThreadExceptionEventArgs t)
            {
                DialogResult result = DialogResult.Cancel;
                try
                {
                    result = this.ShowThreadExceptionDialog(t.Exception);
                }
                catch
                {
                    try
                    {
                        MessageBox.Show(“Fatal Error”, “Fatal Error”,
                            MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Stop);
                    }
                    finally
                    {
                        Application.Exit();
                    }
                }
 
                // Exits the program when the user clicks Abort.
                if (result == DialogResult.Abort)
                    Application.Exit();
            }
 
            // Creates the error message and display it.
            private DialogResult ShowThreadExceptionDialog(Exception e)
            {
                string errorMsg = “An error occurred please contact the adminstrator ” +
                    “with the following information: “;
                errorMsg = errorMsg + e.Message + ” Stack Trace: ” + e.StackTrace;
                return MessageBox.Show(errorMsg, “Application Error”,
                    MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Stop);
            }
        }

    }

However this should be the default behaviour.

How Many Languages?

These days is is unlikely that one language is enough to get the job done.

Today I used:

  1. Delphi
  2. SQL
  3. Expect
  4. Python
  5. Want

I use compiled languages for the heavy lifting.
SQL is for data manipulation (mostly stored procs).
Expect and Python provide the flexible utilities (database creation).
Want (the delphi port of ant) provides the build tools.

Where are C#'s meta-classes?

In Delphi you can define a meta class and pass classes into methods.

TFoo = class(TObject);

TFooClass = class of TFoo;

function MakeFoo( aFooClass : TFooClass ) : TFoo;
begin
    result := aFooClass.Create();
end;

This allows very generic code where you can get away with just passing in a class name.
I use this heavily in Delphi as part of a test framework (the meta class represents test data).

I think that this can be done in C# using reflection but there should be a cleaner method.