John Kaster

Behind the Screen

Archive for the ‘Delphi’ Category

Delphi Cookbook review

leave a comment »

Review of the book Delphi Cookbook by Daniele Teti.

Before proceeding with my review, you may want to read this other review by Simon J Stuart which provides a good overview of what you can find in the book. I also received a review copy from the publisher, and Iā€™m glad I requested one!

Overall impression

The book uses a great pattern, where a topic is introduced, code is shown to demonstrate it, explanations and observations about the technique are discussed, and suggestions for additional usage or other resources are provided. This “explore more” section of the book may actually be its most valuable part, because Daniele provides specific links that point to good resources to use for each of the recipes covered.

The code examples are useful and as concise as is reasonable.

The order of the book is logical and does a good job of building on some of the previous recipes in later parts of the book:

  1. Delphi Basics
  2. Become a Delphi Language Ninja
  3. Going Cross-Platform with FireMonkey
  4. The Thousand Faces of Multithreading
  5. Putting Delphi on the Server
  6. Riding the Mobile Revolution with FireMonkey
  7. Using Specific (mobile) Platform Features

This is a valuable book to keep handy for when you may need to implement any of the techniques it covers. In short, it is exactly what a “cookbook” should be, with quick and reliable recipes to help you create a good solution for a technical issue.

Some specifics

For example, there’s a great, short exploration for taking advantage of generics. Hidden in one of the discussed “higher order” functions for generics (map, reduce/fold, filter) is something that deserves to be called out briefly in the book (although it is not).

class function HigherOrder.Filter(InputArray: TArray;
    FilterFunction: TFunc): TArray;
var
  I: Integer;
  List: TList;
begin
  List := TList.Create;
  try
    for I := 0 to length(InputArray) - 1 do
      if FilterFunction(InputArray[I]) then
        List.Add(InputArray[I]);
    Result := List.ToArray;
  finally
    List.Free;
  end;
end;

 

This small sample shows one of the cleaner methods of populating a dynamic array result that can subsequently be lifetime managed by the runtime.  The TList object is efficient for growing one item at a time. A dynamic array is not. Often, the result for the dynamic array is preallocated to some high bound (in the sample above, it would be the length of the input array), then resized before the return to shrink the array back down to the number of elements matching the filter. By using TList<T>, then freeing it, the array size is only manipulated once and the List.ToArray call makes the code clean and sustainable.

Mobile development with Firemonkey

The book has many detailed and useful examples for mobile development with FireMonkey. This is the section of the book where I learned the most, because I haven’t worked on mobile apps with Delphi. There are many useful tidbits covered in this section that are important for mobile development: using mobile databases, implementing server and client-side functionality, camera and phone manipulation, application lifecycle awareness, and more.

Platform-specific features

The platform-specific features chapter goes beyond mobile FireMonkey recipes to making calls from Delphi to iOS and Android SDK calls, and is an excellent way to wrap up the book.

Other recipes I’d like to see

Some things I think would be good to have in the book are:

  • In the UI section:
    • effective use of actions
    • effective use of frames
    • input value validations (form validation)
  • in the section on streaming, it would be handy to explore reliable determination of the encoding used by a file.
  • for threading, effective use of the new XE7 Parallels library
  • for Delphi on the server,
    • how to secure your web application (including using secure CDN resources for jQuery, etc)
    • using dynamic arrays and records for JSON to avoid all the “free” calls for TObjectList<T> (this works very well with SuperObject, for example)

A minor nit

I don’t understand what Daniele means by “bounce” as in: “I see too many business applications that are composed by a bounce of dialog windows.”

Conclusion

Daniele did a great job on this book, and I hope he continues to update it with new recipes in the future.


	

Written by John Kaster

November 26, 2014 at 8:31 am

Posted in Delphi

Moving on

with 50 comments

On December 27th, 2010 I will leave Embarcadero to pursue a great opportunity for myself. Please don’t view this as a sign that I think Delphi, InterBase or any other of the Embarcadero products is in trouble. Nothing could be further from the truth.

Delphi XE is my favorite version of Delphi, ever. I have even gone so far as to call it “my” release. It has features in it (particularly some of the new DataSnap features) I’ve been wanting since Delphi 5. Really! It has great quality and performance, and I really enjoy working with it every day. Furthermore, the next release looks like it could be the most exciting release since Delphi was first launched in 1995.

Having said this, you’re now probably wondering why I’d be leaving Embarcadero if I feel that way about Delphi and its future. That’s a fair question. I hope you give me a fair chance to answer it, by reading this post to learn why I joined the Delphi team, and why I’m now leaving.

When I graduated from college in 1985, I sent my resume to Borland, because I wanted to work for the company that made Turbo Pascal. I never received a reply. I had already started building things in Turbo Pascal for my own use before I even left college, and these tools rapidly grew into popular public domain, shareware, and commercial products, which I sold and supported. Even while working as an employee of other companies, I kept building software development tools on the side, based on my own needs. 

After a couple years of working as a PC expert, consultant, and systems analyst for lots of major organizations in the Washington, DC area, I went out completely on my own.

In 1997 (12 years after sending my resume to Borland), while deeply engrossed in running my own very enjoyable and successful one-man product development and consulting firm, I got a call from a  head hunter that ended up changing the direction of my career for more than a decade. Based on the deliberately vague description he gave me of the position he was trying to fill, I knew the job involved working on the Delphi team.

I love using Delphi even more than I liked Turbo Pascal, and I thought it would be great to be a part of the team building the product. The thought of personally contributing to its success, and helping shape the product as one of its Product Managers was very appealing to me.

On the other hand, I had my own customers, whom I liked, and my own products, which I really liked, and I was making really good money from the combination of software consulting and product sales.

I was really tempted by the offer, but I was having a hard time deciding which direction to go.

So, I discussed the idea of putting my own business on hold with one of my best friends, Ali Davachi. At a Clipper conference back in 1990, I’d met Ali when he bought two copies of one of my products (TechWriter) with great panache. In the following years, we worked together on some projects, and I have great respect for both his business acumen and technical skills. We also have a fabulous time working together.

Ali said he thought it would be a great idea for me to work for Borland for 2 or 3 years, to get some experience working as a Product Manager on a major product I loved, from an industry-leading software company.

So, I accepted a huge pay cut to “get in the door” at Borland as a Product Manager. I started working as the Enterprise and Distributed Computing Product Manager on November 3, 1997. I was responsible for everything related to database connectivity, and anything to do with DCOM, CORBA, or any other distributed technology. This included the BDE, MIDAS (now DataSnap), and a variety of other “connectivity” technology that has come and gone.

After working in that role for about 1.5 years, I went to work for David Intersimone (David I) in Developer Relations. I became an “evangelist”, traveling all around the world, launching new versions of our products. Together with David and Charlie Calvert, I also launched what is now called EDN in 1999. Ever since then, I have managed, built, and maintained services for EDN, even while traveling.

When Embarcadero acquired CodeGear, I officially became the EDN Program Manager, which is basically what I’d already been doing for over 10 years. This is still my primary responsibility at Embarcadero. I still get to use Delphi to develop services for EDN, and I am constantly in conversations with the Delphi, RadPHP, and InterBase teams about their products, how they are used for EDN, and what I’d like to see in future releases.

A few months ago, my friend Ali contacted me. He told me he was accepting a position as CTO at a great new company called Transactis, and he thought it was the opportunity we’d both been waiting for: to work together again on great technology and services for our customers. In short, he made me an offer I couldn’t refuse. On January 3rd, 2011, I start working for Transactis as their Senior Vice President of Development, reporting to the CTO (Ali).

I will miss the people I work with at Embarcadero, the products I use, and the EDN services with which I’ve worked for so long. It’s very hard to leave, particularly because the projects never stop. But for me personally, this is an opportunity I can’t pass up.

Delphi will be just fine with me gone. EDN will be just fine, too.  As I pointed out in a previous post, many, many people have worked on EDN over the years. Many more have worked on Delphi over the years. Even more people will work on Delphi and EDN in the future.

I’m just one person, who stayed on the team 5 times longer than I originally planned, helping support Delphi. You don’t owe me any favors, but I’ll ask one anyway: if you share my love of Delphi, don’t worry about my departure, and don’t let others make it into some huge disaster for the future of Delphi. My departure has nothing to do with how I feel about Delphi, C++Builder, RadPHP, InterBase, or any other Embarcadero product. Even though I’ll no longer be “on the team,” I’m still a huge supporter of the Embarcadero products. I still plan to use them whenever I can in my future work.

In fact, Transactis will be buying some Embarcadero products in the very near future, so Embarcadero has just gained yet another customer! Smile

Keep the faith, and I’ll see you around.

Written by John Kaster

December 16, 2010 at 2:05 am

Subversion integration inside the Delphi editor

with 7 comments

A couple days ago I asked Dave Wilhelm about checking in the active file in the Delphi editor into my subversion repository, and he pointed out a feature I had missed in the new subversion integration in Delphi XE.

  1. Right mouse click on the editor pane with the file you want to check in as the active tab.
  2. Click Version Control
  3. Cick Subversion
  4. Select Commit
  5. This brings up the commit dialog for that file if it has changes to be committed. Fill in the comment (good practice) or not (bad practice), and commit the file.
  6. You’re done.

See http://johnkaster.com/images/jing/2010-11-18_1447.png for a screenshot.

Written by John Kaster

November 18, 2010 at 4:02 pm

Posted in Delphi

More information on dbExpress and DbxUtils

leave a comment »

Materials on my CodeRage talk about dbExpress materials are now available.

The slides are available here: http://cc.embarcadero.com/Item/28067
The recording is available at http://channel-e.embarcadero.com/index.php?option=com_jvideodirect&x=1&v=clHQ85uCbU225

DbxUtils.pas is available in the sourceforge RAD Studio demos project.
https://radstudiodemos.svn.sourceforge.net/svnroot/radstudiodemos/branches/RadStudio_XE/Delphi/Database/dbExpress/Utils

We’re relying very heavily on DbxUtils for the new QualityCentral DataSnap/REST server I’ve briefly discussed on EDN. The unit tests both for DbxUtils and QC are proving that DbxUtils is quite robust and stable.

Written by John Kaster

November 12, 2010 at 5:34 pm

Using DataSnap/REST with QualityCentral

leave a comment »

In case you haven’t seen it yet, I’ve started writing about the process of implementing the new QualityCentral middle tier in DataSnap/REST.

This first article is an extensive introduction to DataSnap/REST that provides step-by-step details on building, debugging, and deploying a DataSnap/REST ISAPI dll: You can read it at http://edn.embarcadero.com/article/40873.

The second DataSnap/REST article begins the discussion of developing the new QualityCentral middle-tier. It’s called “Connections with DataSnap” and can be found at http://edn.embarcadero.com/article/40890.

The new middle tier is already heavily using the routines from DbxUtils.pas. I’ll be discussing some of those routines at CodeRage 5 (http://www.embarcadero.com/coderage5/sessions) on Friday Oct 8th at 9am Pacific time. (A little over 9 hours from now).

Written by John Kaster

October 7, 2010 at 11:37 pm

Korean developers brave Typhoon to see RAD Studio

leave a comment »

I was just in South Korea, participating in the launch event for RAD Studio XE. Early the morning of the event Typhoon Kompasu hit South Korea. It’s been called the worst typhoon to hit South Korea in 10 years. I extend my condolences to the families of those who lost their lives in the typhoon. I would also like to thank our very dedicated and enthusiastic Korean Delphi and C++Builder developers (about 180 of them) who still made it to the RAD Studio launch event. That shows some real dedication. We had more than twice that many people register for the event, so I’m hoping we can get the rest to come see the XE version another time soon.

Agenda slide

The agenda for the talk

In my presentation, I spoke briefly about Embarcadero and what we’re doing, provided the RAD Studio overview, and demonstrated what’s new in the products. My talk was translated from English to Korean. Other parts of the launch were covered by Korean speakers ,so they could cover more material faster. I do appreciate the audience’s attention while listening to the serial translation.

Debugger features

Demonstrating new debugger features

Talking about Help Insight - an unfamiliar feature

The other speakers were WK Kim, Jun Kim, and Jeehoon Imp Park. WK Kim discussed DataSnap and the new cloud development features of XE. Jun Kim discussed agile methodologies in general. Jeehoon Imp Park demonstrated AQTime, CodeSite, and FinalBuilder.

Jeehoon, WK Kim, and me

The people at DevGear, our partner in Korea, are really great. They organized and put on a great event, even in the aftermath of a typhoon.

DevGear staff

WK Kim is crouching directly in front of me (in the blue jeans). Beomyong Park (the head of DevGear) is to my left, and Jeehoon is next to him.

Next stop, Mumbai, India!

Written by John Kaster

September 4, 2010 at 5:45 am

RAD Studio Tip #1: Quickly configuring MySQL to use with dbExpress and Data Explorer

with 7 comments

When developing and debugging applications for EDN, I use several different Windows VMs for various reasons. Periodically, I want to use the RAD Studio Data Explorer to look at some values in a MySQL database. If libmysql.dll (the MySQL driver dll) is missing from the machine or not in the right path, I typically see this error when trying to view a MySQL database with Data Explorer:

DBX Error: Driver could not properly be initialized.
Client library may be missing, not installed properly, of the wrong version,
or the driver may be missing from the system path.

The MySQL dll is freely available to download from http://dev.mysql.com/downloads/mysql and the install available there usually will put the libmysql.dll file dbExpress requires in a path that allows dbExpress to load it.

This is good for setting up for one machine, but once you have a copy of that dll available, nothing else is required to access MySQL from dbExpress. So, when I need to configure a new machine for MySQL access, I just copy that dll to the appropriate path on the new machine.

For 32-bit Windows machines, libmysql.dll should typically be in c:\windows\system32.

For 64-bit Windows machines, libmysql.dll should typically be in c:\windows\SysWOW64.

Once dbExpress can find this dll, all you need to do is restart the IDE and you should be ready to access your MySQL databases either locally or remotely.

I hope this simple tip helps ā€“ I use it frequently enough, I decided it was worth blogging about. šŸ™‚

Written by John Kaster

August 6, 2010 at 1:29 pm