Montag, 2. Oktober 2017

Facebook?

Using Facebook or this blog?

OK - Perhaps technical Infos in this blog and Funstuff on Facebook...

I have to look for a cat using my FDK for the best Facebook user experience...

btw: https://www.facebook.com/delphiprofi.de/

Sonntag, 24. September 2017

Forentage 2017 - Sonderaktion

Hallo Zusammen!

Leider hatte ich die Bestellformulare mit einem Sonderpreis für mein FDK - im Auto - im Kofferraum -  im Saturnparkhaus vergessen.

Natürlich hätte es eine Sonderpreis für Bestellung auf den ForenTagen gegeben!

Also: Befristet bis zum 15.10.2017 gibt es mein FDK für 349,- € (statt 399,- €)

Einfach das Setup downloaden und registrieren!!

Infos unter : http://delphiprofi.blogspot.de/2016/05/fdk-das-firemonkey-development-kit.html

Die nächste Version ist in Vorbereitung.

INFO: Die MVVM-Teile sind zur Zeit noch nicht enthalten!


Dienstag, 5. September 2017

Scanning barcodes the FDK-way

You like to scan barcodes in your app?


Ok, you probably googled this topic! But you will find solutions only for iOS or solutions only for Android. Perhaps a preinstalled thrid-party app must be installed.


Of course there are solutions for both platforms, but for free?


And how long does it take to integrate this in your app?


Perhaps you consider the FDK approach:


Uses
   Delphiprofi.FDK.AnyFactory,

   Delphiprofi.FDK.Barcode;


var
  FScanbarcodes : ICanScanBarcodes;


procedure TFormMain.ScanClick(Sender: TObject);
begin
  FScanbarcodes := TAnyFactory.Factory.CreateObj<ICanScanBarcodes>;
  FScanBarcodes.ScanResult(Procedure (AResult : String)
    begin
      LBLScanResult.Text := AResult;
      FScanbarcodes := NIL;
    end).Scan;
end;



Internal I'm using the ZXING Source for Android. For iOS you can choose between the ZBar or the ZXING version. ZBar ist based on the TMSWrapper for ZBar!


The ZXING Version is inspired by MVP Andrea Magni, but without the FrameStand and other overhead.


Threading is done with my TAnyCommandProcessor, that can queue the workflow for the Bitmaps, that are captured with the TCameraComponent!

Dienstag, 15. August 2017

#WhyIChooseDelphi


Why I Choose Delphi?

Starting with UCSD-Pascal in school on Apple II. I used my Sharp MZ-800 (Z80 CPU) with CP/M and Turbo Pascal 1.0. I had a special utility to write IBM-Disks on MZ-800. So I was able to transfer my “homework” to the IBM XT, to show my work in school, with Turbo Pascal 1.0, too.

At this point, I got an offer to do program a business application. This application was my first real Pascal application, too.
Before that, all my programs were programmed in Z80 assembler, like my own 1000 byte Disk-Operating-System - FL-DOS from 1986.

To keep necessary procedures together, I collected procedures in “one” Pas File called Runtime.pas.

“Yes”, this unit is still alive today, but called Basis.pas and wBasis.pas for Windows-Stuff. I collected million lines of source-code and unites over the years. Some have changed but many are still in use.

Starting with e.g. C# would take me month or years to reproduce my “runtime” core procedures.

That is the practical side. Beside this, for me, a compiler has to produce an exe…
No P-Code, no script no runtime interpretation. “My” compiler has to produce a standalone application that brings everything with it. No runtime stuff that had to be prior installed.

Ok, .NET was a “not so bad idea”. To have code that could be optimized for the given CPU at first run. Do we have this kind of “run on RISC-CPU” environment?

So let’s compare:

#C could be a choice, because the code is like Pascal or not so far away!
C / C++, source code looks like someone had rolled an Armadillo over the keyboard.

End of List…

Yes, you can do everything in Delphi! However, If you are looking for some special things, you always find source in C* but not in Delphi. For this small parts. Compile with C* link an object or use a DLL, done.

Have I tried to switch to C#? Yes but, I’m so much faster in writing Delphi… It was a waste of time and btw. I hate the MS-IDE. (I still use the original WordStar key mapping from my early days on CP/M).
Remember the famous words: “The clueless people shall spend their time reinventing the wheel, while the elite merely use the WordStar key mappings”.

Let us not talk about Pascal / Delphi as source-code. One of the big thing is productivity. The IDE and the compilation speed. Turn cycles are a major point in development.

Set Breakpoint, F9 to compile and start, debug, STRG-F2 to stop, change something and hit F9 again…. If you like, you can do this thousand times in an hour.

For many years I took the RAD approach – button on the Form -> double-Click -> and go with the code… Why not!
This was the time where nobody talked about design pattern, separation of form and code or other things. Why? No Internet…
Yes, I know the Internet starts at 1989/1991 and my Application was for Win95. However, when did you start your first AOL Internet over Hayes-Modem “You have new Mail” – Client?

We don’t talk about Borland-Pascal for Windows – But I had a small working Demo of my Software, simulating the DOS-Screen in a Windows-Frame… (If you ask me, I’ve never done this).

My Company depends on Delphi and I have no problem with this…

Because Delphi is the best development tool, I’ve ever seen.

Sonntag, 30. Juli 2017

SQL, how do you write your queries?

OK - I know there are many ways to do a simple SQL Query... Like:


Query.SQL.Text := 'SELECT * FROM PersonDB where LastName LIKE "'+ALastName+'%" order by LastName,FirstName ASC LIMIT 50';


of course using Parameter is a better way, like:


Query.SQL.Text := 'SELECT * FROM PersonDB where LastName LIKE :0 order by LastName,FirstName ASC LIMIT 50';
Query.SQL.Params[0].AsString := ALastName+'%';



Perhaps you set you statements in the ObjectInspector or you copy the statement from an other tool.

But what if you are new to SQL?

What kind of errors happens in your SQLQuery?
Misspelled fieldname? Missing brackets, missing space or ",".

The problem is,- normally -  you can only find  this errors by executing the statement...


In my FDK I have all database definition in my sourcecode. All fields can easily checked against this definition.

If I do a search for a Person in my PersonDB, I like to shorten the search result by typing not only the Lastname... I like a search of both Firstname and Lastname.

If I search for my name in this database I can put "Lau,Fr" into the Searchedit and I get the result of all Person starting with the Lastname LIKE "Lau%" and FirstName LIKE "Fr%".

Perhaps you do other combinations.
In this case you always have an If or Case statement to select the right SQL, - or - to Ignore NULL DB Fields.

In my latest development of my ORM/CRUD DB Interface, I tried to include this expectations in my FDK.

For the given search problem I have this solution in every application:
 
procedure TPersonViewModel.Search(Const ASearchFor : String);
var
  FirstName,
  LastName  : String;
  P         : Integer;
begin
  LastName  :=  ASearchFor.Trim+'%';  
  P := Pos(',',ASearchFor);
  if P > 0
    then begin
          
FirstName := Copy(LastName,succ(P),
                             Length(LastName));
           Delete(LastName,P,Length(FirstName));
         end
    else FirstName   := '';

  // Normally
  if FirstName.Trim = ''
    then
Query.SQL.Text := 'SELECT ...'// Without FirstName
    else Query.SQL.Text := 'SELECT ...';// With FirstName
end
;


But I don't like this untestable SQL in this procedure. So I came up with this:


procedure TPersonViewModel.Search(Const ASearchFor : String);
var
 
SearchResult : ICanCRUDSearch; // from my CRUD-Framework
 
// .. Same as above
begin 
  // .. Same as above and then
 
  TCRUDSearch.&For(FPerson).

   {} Where('LASTNAME').LIKE(LastName.Trim).
   {}   begin_Optional(FirstName.Trim <> '').
   {}     _AND.Where('FIRSTNAME').LIKE(FirstName.Trim).
   {}   end_Optional.
   {} OrderBy('LASTNAME').OrderBy('FIRSTNAME ASC').
   {} Limit(100).
   {} Start(SearchResult);

   if SearchResult.SyntaxOnly then
     exit;
   // Perform UserIO on SearchResult
end;


And for Unit-Testing you can just call this same procedure and "Start" performs a systaxcheck only.

Perhaps you call it "Over Engineering" - I call it helpful. And more:


I love this kind of fluid-source-code. It's so easy to read and understandable.

The {} in front of each line are only to prevent the sourcecode formatter to kill my structure.


The Fluid-Interface helps you to build your statement - of course you should know a little bit of SQL, but...e.g.


After "Where" you can only use a comparer "LIKE, EQUAL, GREATER...". That's why "Where" is defined as



     ICanCRUDWhere = Interface
    Function  Where(Const AName : String) : ICanCRUDCompare;
  end;

  ICanCRUDCompare = Interface
    Function  LIKE(Const AValue : String) : ICanCRUDSearch;
    Function  EQUALS(Const AValue : String) : ICanCRUDSearch;
    // more...
  end;


The SearchResult stores the Data and you can iterate through it.

My FDK.FMXGridHelper can take this SearchResult and could direct perform the UserIO.

The CleanUp is done by RefCounting automatically.

Stay tuned for the next FDK update... More is coming...

Freitag, 14. Juli 2017

Which Delphi Language Features are necessary?

Long time ago I was very satisfied with (Turbo)-Pascal.


Everything was fine! My world full of Records, (Fixed)Arrays and Shortstring has made me happy.


There was no need for a Database - I could read and write my Records - as easy as it could be - with blockread and blockwrite...

At this time I was able to write any program I wanted. (for the Kids: Program was the name in these days, today you would call it App)

Then "suddenly" records where bad and I "had to" use classes...


Too Bad... No block-read/write any more.. At this time you had to use Streams... (It finally leads to the same call, but "nobody" knows this...) 


Next Step: You could do fancy things with class operators and implicit. So back to Records?


Then, "suddenly" classes are bad and you have to code against Interfaces to decouple things for Unittests. Have you ever done Unittest in these "old" days?

As time goes by, new compilers were ignored... Delphi 2007 could be used for everything... Windows, Windows-Server(ISAPI.DLL) and ASP.NET...

Sometimes I took a look at new compilers, but without ASP.NET and this new very bad thing called Unicode,  I ignored  them.

So let's jump a few years into mobile development... Many new stuff...
Zero based Unicode Strings - no more Ansi- or Shortstrings, ARC, ARM, 64 Bit, Attributes, Generics, TPL and more...

After 6 years of development - using "new" language features - this features become so handy that I hate every hour of programming old apps with Delphi 2007.

Unbelievable, have you tried "cool stuff" without Generics, lately? Not using generics is like doing the same stuff over and over again. In the old day's we called it copy&paste (OK, Generics is doing copy&paste internally, but it feels better).
And what's about Unit-Test? Are you still using a Hello-World-One-Button-Apps with a Button labeled "Button1" on it to test new Source-Code?

Testdriven-Development - That is the right workflow to speed up development. Of course with Testinsight as you can read in my blogpost from April.


Do you want to see the power of Testdriven-Development - visit my Session at Forentage 2017.

Using new language features? All I can get...





Forentage 2017 - Meine Session.

Hallo zusammen! (English text below)


Ich habe gerade die Bestätigung für meine Session auf den Forentage 2017 erhalten.

Ich nenne sie:


MVVM-Lite oder wie man eine Trennung von Form (View) und Logik (ViewModel) mit ein paar Zeilen Code erreichen kann!


Eine Voraussetzung für die Testbarkeit von Programmen ist die Trennung von UI und Logik, diese Session zeigt, wie dies - ohne die Verwendung eines Framework - mit den einfachsten Möglichkeiten unter VCL & FMX erreichen kann.

Um eine schnellere Entwicklung zu erreichen, werde ich diese Session als Testdriven-Development zeigen.




Hello Everybody!

I just got the confirmation of my session on the Forentage 2017.



I call it:

MVVM-Lite or how to achieve a separation of form (View) and logic (ViewModel) with a few lines of code!

A prerequisite for the testability of programs is the separation of UI and logic, this session shows how to do this without using a framework - with the simplest possibilities under VCL & FMX.

To achieve a faster development, I will show this session as Testdriven-development.


Lesson is in German language. If I find the time I will do an english video later...