Saturday, September 28, 2013

Delphi Experts and IDE Plugins I Love - Part 1: GExperts

Maybe every Delphi Developer in the world already knows about GExperts. Maybe there are a few that don't.  I'd like to point out a few things that I find make GExperts worth having around. Most Delphi users probably know it exists, and know it's open source, and that it's awesome.  Oh you didn't know that? Well then, you're the person that I wrote this blog post for.

But first, I must tell a side-story.

A job or two back in my long and glorious employment history, I worked beside a very smart Delphi guy which we'll call Dave.   He had his own cool plugin for Delphi that had its own special File Open mode.  After working with it for about 2 days, I was hooked on one feature. I had the keyboard shortcut Ctrl+Shift+O hard wired in my brain to a dialog box in his expert that would open a search window that let me search for any unit in the library path, current project, or current project's search folders.   Dave was a smart guy, and a really highly effective Delphi developer.   He had become quite used to a now defunct IDE add-on for Delphi called CodeRush. There is still a Visual Studio plugin by that name, but the Delphi version of CodeRush is now only a fond memory for those of us who left behind Delphi 7 for good. Delphi 7 was the last version of Delphi that could accept CodeRush.  Anyways, Dave learned enough about the open tools api (OTAPI) and got busy building the productivity enhancements he needed.  Kudos to Dave.

Anyways, there were a million things in that plugin but there was only one thing in it that I got so addicted to that I couldn't live without it, once I got used to working that way.  It was an efficient file-find and open dialog.

 If I knew a unit's name, or the first few characters of it, I would simply do the following:
  • Hit Ctrl+Shift+O
  • Type the beginning of the unit name, like uWarehouse, and press enter.
  • If there was a uWarehouseObjects.pas in my project or somewhere in the search paths (library or project settings), it would now be open and I would already be editing it, instead of thinking about it.
After I no longer worked there, I was bereft. So I downloaded CNPack (which will be the focus of Part 2 of the Experts and IDE Plugins I love) and tried its Open dialog boxes.  It has a few wizards that have overlapping and slightly different takes on this concept, but none of them worked as well as the in-house one I was used to.  Then I download GExperts, which is open source, figuring that if it wasn't QUITE what I wanted, I could always quickly hack a bit on it, and make it what I wanted.

Why don't I just use the IDE Insight feature? Three reasons.  One, I still do a lot of work in Delphi 2007, which lacks IDE Insight. Two, IDE Insight finds things that are not files, and this throws off the Emperor's Groove.  Do not -- I repeat do not --  throw off the Emperor's Groove.    Three,  because the Ctrl+Shift+O pattern is hard-wired into my brain now.





These days, I can not live without GExperts installed in Delphi, and Ctrl+Shift+O mapped to the GExperts open window which has a search box at the top and a series of tabs:  (click to see a larger image)

Now Dave's in-house file-open wizard was actually easier to use at first, in my opinion because it didn't split the Project units and the units found in the search path or the VCL source folder out into their own tabs. However, once I got used to this divided approach, I decided NOT to hack GExperts to merge the tabs above.  If I do hack it, I think I would actually populate a VirtualTreeView with categories I could expand and contract and then have some registry preferences to remember which sections are  expanded or collapsed. I chose the above examples because the word MAIN is not even the beginning of the unit name, it just appears somewhere in the unit name.

Since for 99% of my use, I only want files from the project, I just work in the Project tab 99% of the time these days, and the odd time or two I may flip over to the Search Path.  I also use the Favorite tab to bookmark units, and then return to those bookmarked units. Imagine you're fixing Bug # 1234, and it's involving a set of units that you have to flip between a lot.  With all the other tabs that get open in the Delphi editor tabs, sometimes it helps to just Close All Tabs after you save all, and then, when you need a tab again, just use Ctrl+Alt+O (or whatever keyboard shortcut you choose) and go to the favorites tab, which is only a few clicks.   I use this as an alternative to what Java/Eclipse or XCode programmers would achieve using the project-manager views in their IDEs, which let you move and organize "virtual folders" freely in your project or workspace, folders that have NO relationship to the real physical source code organization on the disk.

One feature that I probably will hack into the GExperts open dialog is the ability to open a form by its Caption instead of by its unit name.  Many units in the code I work in may have started out in TurboPascal for DOS with its cryptic 8 character limits on filenames.  If you can't remember that ECL.pas is the Accounts Receivable main form, because some guy decided to call it ECL, for no reason you can figure out, you'd probably like such a feature too.

Muscle Memory and Keyboard Shortcuts

One of Dave's mantras, and it was a good mantra, was that learning keyboard shortcuts increased your productivity. Most of his wizard's features were designed to be used by keyboard shortcut.  I have found that this principle has been true for me too;  If I learn a keyboard shortcut well enough to use it without thinking, it will increase my productivity.  Any menial task that could be done by an Expert (an IDE plugin) when I hit a hotkey, can save me minutes, or even hours of time, that I should be spending solving problems, or making new features on the products I'm paid to work on.

Other stuff I use in GExperts:

i. Components to Code.  Copy a complete component or selected set of components, and have GExperts write the code you would need to instantiate these components from a .pas unit without any .dfm.   This can be a fantastic way to start out the job of creating a Composite Control which takes several VCL Controls and makes a nice reusable new control that groups several individual controls, such as your own Date Time Picker or something like that.  

ii. If you ever spent time manually aligning elements in your code, like assignments on multiple lines,
because you hate leaving them ragged, then GExperts will get you back on your way and writing the code your Boss is really paying you to write, and not wasting your time on Whitespace.   Ctrl-Alt-Z is the
alignment editor feature in GExperts, here's one of the many little jobs it does for you.  In this example, two lines of text, you would hardly need this feature, but imagine you wanted to do this in a 30 line or 50 line
block of record field assignments.


There are literally thousands of little features, and twenty or thirty major features in GExperts, but I would like to advance the idea that if you try to use all of them, you'll go crazy. Just find one that you need, and use it, and if it improves your productivity, add another tool from GExperts, when you need it.

GExperts has the ability to uncheck features you don't want, so disable every feature except the Open Dialog feature, or unmap all the other hotkeys anyways, and then add one hotkey at a time.  I think that opening files is something you are always going to be doing, every day you work with delphi, and unless you are already happy with the F6 feature (IDE Insight) in Delphi XE or later, you need GExperts, even for just this feature. Note that if you still have to support projects in Delphi 7 or 2007,  GExperts works in those old versions, as well as in the latest versions, all the way up to Delphi XE5.



In part 2 and 3 of this series  I plan to cover the other wizards that I can't live without, and in part 4, I will briefly mention some of the IDE Plugins that I do not use, but which are out there, and you should know about, in case you need the features they provide.

Part 2:  CNPack, the Chinese Delphi Developer's Wizard project. (Open Source), which I also only use less than 10% of.

Part 3:  Model Maker Code Explorer (Commercial) , a commercial plugin I absolutely adore.  I will discuss why I think most, if not all Delphi developers would benefit from using it.

Part 4:  A brief overview of Castalia, which I do not use, and do not own, but which I have tried a few times. Many many Delphi developers seem to like it, so I'll cover it.

If there is any interest in the matter, I'll write a Part 5, which is a brief tutorial on starting your own tiny IDE wizard, and how to get started either modifying the GExperts wizards, or writing your own wizard, including an introduction to the OpenToolsApi (OTAPI). I'm nowhere near as good at that as "Dave" the guy I used to work with, but then, few people are.

If you write code in Delphi for a significant portion of your day, then I urge you to experiment with the available options for fast finding and opening of units in your project.  At least start using F6 (IDE INSIGHT) if you're not using it, on Delphi versions that support it. If you find it isn't just right, then try GExperts.

Note to XE5 users:  XE5 binaries have NOT been relerased, but a pre-release Alpha (unstable) build by Yours Truly is available to download here.  If it has bugs, I suggest you fix them yourself, and contribute back to the GExperts project.  

Wednesday, September 11, 2013

XE5 Trial Download and Install Experience

I haven't received any SA emails, but XE5 is up and the trial is downloadable now, so go try it out folks.

I downloaded the trial and it installed and activated the trial flawlessly. The android stuff you need is all automatically installed, and even somewhat configured. (An emulator profile for XE5 is created, for example. Nice!)

A launch webinar is planned for Thursday September 12, go sign up now.


I haven't been able to test XE5 with my real Google Nexus 7 yet, because my wife is addicted to Scrabble, and I haven't got the heart to steal it from her. Tomorrow evening I will, however.

Tonight I just used the emulator, and I have to say, that the Android EMULATOR is a piece of crap, and that this is not Embarcadero's fault.  I have already long lamented the crappiness of the Android EMULATOR technology that comes in the Android SDK/NDK.   If you want to try this out, please please please save yourself some grief and just skip the damn emulator completely.



Also, the emulator appears not to properly implement OpenGL/ES, at least not on everybody's computers. It doesn't work at all on my windows 8 computer, which has a high end workstation graphics card.  That means I can't even launch a hello-world firemonkey-android app on my emulator.

I have the Android Studio (new Java toolset from google, based on IntelliJ IDEA), I have the classic Eclipse based Android stuff, and I have Delphi XE5 trial.  I have used the Android emulator with these two IDEs for a while now, and I find the speed absolutely atrocious, and I'm running on a quad-core Xeon box with a lot of RAM, and a very fast hard disk.    So, go get a real Android phone or tablet, before you even start playing with Android.  I recommend the Google Nexus 7.

Anyways, can I just say that I hate Java, and I hate the Android SDK and its intents and its intent filters, and its XML UI building system.

Am I ever excited that, without learning how to properly bean your proxy-factory-intent-filtered snicker-snacks and make them reverse-deionize in a co-variant fashion, while simultaneously generating your user interfaces in giant swaths of hand-coded, XML you could just .....

stick a damn button on a damn form, and run the damn thing. You know what I mean? Yeah.

Go Delphi.

Sorry if that makes me a troglodyte, but that's how I feel.

Thursday, September 5, 2013

Delphi XE5 Launch immanent! World tour on now!

I attended the Delphi XE5 Launch event in Toronto yesterday.   The big news as everybody knows already is that the cross-platform framework Firemonkey (which is going to be marketed as FM now, it seems) has now got support for the Android NDK (native).  That means true native ARM binaries on all 20,000 unique hardware devices so far released for Android, that run one of the three recent and popular versions of Android that this particular NDK tool set can target.  That includes the latest "Jelly-Bean" android, and two popular prior versions, enough I think, to cover most people's needs.

I have not yet used the XE5 product, but as my employer is on SA, I am going to grab it as soon as it's released and will be posting my attempts to build a single source iOS and Android app of some sort.

Exciting times.

Yesterday's launch event had the largest turnout for a Delphi launch that i have yet seen.   I wonder if part of it was the wonderful choice of launch location (Ruth's Chris Steak House), and the innovative lunch-and-learn concept.   Probably there were some people who would have been able to make an evening launch that could not take time off in mid work-day, but that didn't seem to hurt turnout, which was 5x to 10x more people than were at the XE4 launch.  The XE4 launch apparently, did not have proper publicity and emails, and it was good to see that the XE5 launch in Toronto was handled much better.

The presentation focused on the new mobile features, which is to be expected, since they're pretty cool. I'm sure that some of the Delphi faithful in Toronto also want Embarcadero to spend time polishing the core Windows and VCL areas of the system,  but I don't think any long-term Delphi fans (myself included) are sad to see Delphi acquire new cross-platform capabilities that are, I believe, beyond anything anybody else anywhere has right now.  Delphi is out front.  Good news for Embarcadero and good news for all of us Delphi users.  Our secret weapon now has a new set of cool features.   Embarcadero is also committed, it would seem, to sharing with the world, via well-done marketing, that Delphi XE5 has a few new tricks up its sleeves in the productivity Force Multiplier territory that really has been Delphi's key strength even in its single-platform Windows-only days.