Sunday, 26 October 2014

Delphi vs Xamarin

Recently I have been doing some mobile development and assessing the pros and cons of Delphi and Xamarin. Here is a brief list of them, there will be more as I use both.

Delphi Pros

  • Use existing familiar IDE.
  • Quick to prototype and deploy to Android device.
  • Easy to use interface designer.
  • Large shared code base between different platforms.
Delphi Cons
  • Expensive to purchase the latest version of Delphi.
  • Crashes often with the loss of any recent changes.
  • Slow to build and deploy.
  • File size is big, 'Hello world' app will be at least 25MB.
Xamarin Pros
  • Nice to use interface (C# code).
  • Easy and quick to deploy app to Android.
  • File size small, suspect this is due to it having to also deploy virtual platform.
  • The app is quick to run on the device compared with Delphi app.
  • Cheap compared with Delphi.
Xamarin Cons
  • Less shared code between platforms.
  • Interface designer does not feel as flexible.
  • Properties inspector needs improving and is not as user friendly as Delphi.
  • Online tutorials and help are not concise and some seem out of date.
I should point out the version of Delphi I used was XE5, the current release is XE7 so they might have fix a few bugs. I did go to a XE7 launch event (which I will write another blog entry about) and from what I saw and the questions I asked it is not much different and they have not done anything to improve the build time. When it comes to the speed of the build for Android it is best to build to the device rather than use the Android simulator which for both is very slow.

I will continue to add to this blog entry with other pros and cons as I come across them.

Sunday, 27 July 2014

Delphi XE Android App Emulator Problem

I have recently been using Delphi XE5 do produce an Android mobile app. All was looking good until I wanted to run the app, the Android SDK comes with an Android emulator, but when I tried running the App from Delphi with the emulator running I just got a blank screen. When I plugged an Android device in it ran fine, so I thought it must be an issue with the emulator. After a few days of using the device I thought I would look into how to fix the emulator issue. All you need to do to fix this problem is to turn on the 'Use host GPU' option when setting up the device in the emulator, after that it will run, however there is another annoying issue, it is very slow.

Monday, 3 February 2014

Using TObjectList in Generics.Collections

In 2009 a new TObjectList was introduced in Generics.Collections, the old TOjectList was still available in the Contnrs unit, but the new one was more strongly typed and you need to specify the class of object the the list will be populated with. This means a reduction in type casting. Here is an example of how to use it:

TMyListClass = class(TObject)
   private
        FEntries: TObjectList<TMyEntry>;
   public
        property Entries: TObjectList<TMyEntry> read FEntries                write FEntries;

        function GetEntry(aIndex: integer):TMyEntry; 

        constructor Create;
        destructor Destroy; override;         
   end;

implementation

constructor TMyListClass.Create;
begin
    inherited Create;
    FEntries := TObjectList<TMyEntry>.Create();
end;

destructor TMyListClass.Destroy;
begin
    FEntries.Free;
    inherited Destroy;
end;

function TMyListClass.GetEntry(aIndex: integer):TMyEntry;
begin
   // You don't need to typecast
   // Old way 
   // if (FEntries.Items[aIndex] is TMyEntry) then
   //    Result (FEntries.Items[aIndex] as TMyEntry; 
   Result := FEntries.Items[aIndex];
end; 



Monday, 27 January 2014

DevExpress Grid Modify Date Header Filter

In a DevExpress grid I needed to remove options from the filter that is available from the column header. Because the header related to the date column it put in a load of filter options that I did not require. I managed to do this by creating an OnGetFilterValues event:

MyGridView.Columns[MyGridView.GetColumnByFieldName('MY_DATE_FIELD').Index].OnGetFilterValues := cxGridGetFilterValues;

Then I put the following code in the procedure:

procedure MyFrm.cxGridGetFilterValues(Sender: TcxCustomGridTableItem; AValueList: TcxDataFilterValueList);

    procedure DeleteFilterEntry(AValue: Variant);
    begin
        AValueList.Delete(AValueList.FindItemByKind(fviSpecial,               AValue));
    end;
begin
      DeleteFilterEntry(foYesterday);
      DeleteFilterEntry(foToday);
      DeleteFilterEntry(foTomorrow);

      DeleteFilterEntry(foNext7Days);
      DeleteFilterEntry(foNext14Days);
      DeleteFilterEntry(foNext30Days);
end;

There are more filter options that could be removed, it just a matter of looking at the unit that contains the constants.

Tuesday, 7 January 2014

Value and reference types

Value types
Live on the stack. Examples of these types are the simple types like integers, and records

Reference types
Live on the heap. Examples of these types are objects, interfaces and pointers.

Strings are unusual because they live on both the stack and heap, behavior is on the stack and the storage is on the heap.