Skip to content

Developer Christmas Countdown - December 17 - T minus 8 days

December 17 - 8 days to go - Android client connected to Delphi XE DataSnap Server, the Developer Twelve Days of Christmas

Eight short days until that big guy in red suit, red had and white beard arrives at developer’s houses all over the world.  There’s not much time left to buy your developer friends that special Embarcadero Product gift.  When you give them the one gift, you are actually giving them two gifts with our Buy One Get One Free promotion.

Android Java Client and Delphi XE DataSnap Server

At recent developer conferences in Italy and Brazil, Daniele Teti (R&D Director at bitTime, Embarcadero partner in Italy) showed the audience how to build Android smartphone client applications using Java that work with Delphi XE native code DataSnap servers running on Windows.  The slides for his presentation are available at http://www.danieleteti.it/wp-content/uploads/2010/11/delphi-e-android.pdf.  The source  code for his demonstrations is available at http://code.google.com/p/danieletetidemo/source/browse/#svn/trunk/Brasil%20Delphi%20Conference%202010.

The Developer Twelve Days of Christmas Song

I found a "The Twelve Days of Christmas" Java application on the Internet.  I’ve translated the program to Delphi and added code to generate "The Developer Twelve Days of Christmas" version.  You can find the Java application at http://forums.techguy.org/software-development/681553-programming-12-days-christmas-java.html.  The source code for my extended Delphi version can be found at http://www.davidi.com/TwelveDays/DeveloperTwelveDaysOfChristmas.zip.

Here is the Delphi Christmas Unit source code (uses two TButton and a TMemo components on a VCL form):

    unit ChristmasUnit;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;
    
    type
      TForm5 = class(TForm)
        TraditonalTwelveDaysButton: TButton;
        DeveloperTwelveDaysButton: TButton;
        Memo1: TMemo;
        procedure TraditonalTwelveDaysButtonClick(Sender: TObject);
        procedure DeveloperTwelveDaysButtonClick(Sender: TObject);
      private
        procedure DisplayTheDays(TwelveDaysStrings: array of string);
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form5: TForm5;
    
    implementation
    
    {$R *.dfm}
    
    const
    
    TraditionalTwelveDaysStrings : array[0..11] of string =
      ('A Partridge in a Pear Tree.',
      'Two Turtle Doves,',
      'Three French Hens,',
      'Four Calling Birds,',
      'Five Golden Rings!',
      'Six Geese A-Laying,',
      'Seven Swans A-Swimming,',
      'Eight Maids A-Milking,',
      'Nine Ladies Dancing,',
      'Ten Lords A-Leaping,',
      'Eleven Pipers Piping,',
      'Twelve Drummers Drumming,');
    
    DeveloperTwelveDaysStrings : array[0..11] of string =
      ('A gigabyte pipe at home.',
      'Two awesome tablets,',
      'Three dual-core phones,',
      'Four petaflops,',
      'Five terabytes!',
      'Six funny thumb drives,',
      'Seven caffeine capsules,',
      'Eight gigs of memory,',
      'Nine flawless stored procs',
      'Ten tie dye t-shirts,',
      'Eleven promo booth swag,',
      'Twelve finished projects,');
    
    function DaySuffix(DayValue : integer) : string;
    begin
      case DayValue of
        0 : Result := 'st';
        1 : Result := 'nd';
        2 : Result := 'rd'
      else
        Result := 'th'
      end;
    end;
    
    procedure TForm5.DisplayTheDays(TwelveDaysStrings: array of string);
    var
      DaysIndex: Integer;
      DaysToList: Integer;
    begin
      Memo1.Lines.Clear;
      for DaysIndex := 0 to 11 do
      begin
        Memo1.Lines.Add('On the ' + IntToStr(DaysIndex+1) + DaySuffix(DaysIndex) + ' day of Christmas,');
        Memo1.Lines.Add('My true love sent to me,');
        for DaysToList := DaysIndex downto 0 do
        begin
          if (DaysToList = 0) and (DaysIndex <> 0) then
            Memo1.Lines.Add('and');
          Memo1.Lines.Add(TwelveDaysStrings[DaysToList]);
        end;
        Memo1.Lines.Add('');
      end;
    end;
    
    procedure TForm5.TraditonalTwelveDaysButtonClick(Sender: TObject);
    begin
      // The Traditional Twelve Days of Christmas
      DisplayTheDays(TraditionalTwelveDaysStrings)
    end;
    
    procedure TForm5.DeveloperTwelveDaysButtonClick(Sender: TObject);
    begin
      // The Developer Twelve Days of Christmas
      DisplayTheDays(DeveloperTwelveDaysStrings)
    end;
    
    end.

The output on the 12th day is:

    On the 12th day of Christmas,
    My true love sent to me,
    Twelve finished projects,
    Eleven promo booth swag,
    Ten tie dye t-shirts,
    Nine flawless stored procs
    Eight gigs of memory,
    Seven caffeine capsules,
    Six funny thumb drives,
    Five terabytes!
    Four petaflops,
    Three dual-core phones,
    Two awesome tablets,
    and
    A gigabyte pipe at home.

 If you have other developer gifts on your list, post comments below.  Stay Warm and Well!

Post a Comment

Your email is never published nor shared. Required fields are marked *

Bad Behavior has blocked 4 access attempts in the last 7 days.

Close