Posts

Flotsam and Jetsam #116

  • The Starter Version of Delphi is currently 100% off.  I.e.  Free as in beer.
  • The proper use of comments is to compensate for our failure to express ourselves in code.” – Uncle Bob Martin
  • I continue working hard on my materials for Delphi Developer Days.  If you haven’t signed up yet, do it.  I’m really looking forward to seeing you all there.
  • I’m really looking forward to attending TechBash 2016 at the end of the month here in the Poconos in Pennsylvania.  Not only will there be a great lineup of speakers and a great venue, there will be some old friends there that I’m looking forward to seeing again.  It’s nice to have a world-class event like this so close to where I live – it’s so close that I’m driving, as well as taking advantage of the water park.  🙂
  • And while we are on the topic of conferences, I’ll be at Philly CodeCamp this year as well, on October 21-22.  It’s at the Microsoft Malvern office.  Friday is a pay-for-it all day session, where Saturday is hour long talks and is totally free.  If you are in the area, you should go.  It’s always been very good, and they give away a lot of prizes.
  • The new book is drawing closer.  I know I keep saying that, but I only so because it is true.  It will finish sooner rather than later.  As always, you can sign up to  be kept abreast of things.

Book: Dependency Injection in Delphi

My new book, “Dependency Injection in Delphi” is getting close to being published.  It is a deep dive into Dependency Injection and the Spring4D DI Container. 

It’s going to be about 90 pages long or so, depending on the exact size the book ends up being.  I’ll be publishing it first as an eBook, and then soon after in hard cover. 

You can click on the link above to find out more information, including the chapter list.  Please feel free to enter your email address to be notified about it being published, etc. (You don’t even have to let me know your email address if you don’t want to).

My previous two books – Coding in Delphi and More Coding in Delphi – exceeded my expectations, and I’m very grateful to everyone who bought it.  I know I’ll appreciate the support that Dependency Injection in Delphi receives as well.  Thanks as always.

Flotsam and Jetsam #111

  • My friends David Millington and Roman Yankovsky have teamed up to offer a Christmas time special.  You can buy both of their tools for the price of Fix Insight.  What are those tools?  Well, David’s tool is Navigator – a powerful, easy to use way to navigate your code.  Roman’s tool is Fix Insight – a static code analysis tool.  Right now, you can get both for the price of Fix Insight – that’s a $40 in savings.  I can vouch for both tools as being very useful and of high quality.  Don’t miss this good chance to get two excellent tools at a low price.  (While you are at David’s website, be sure to download the excellent and free Bookmarks plugin. And did you know that he has some open source items available as well?)
  • ‘Tis the season for Delphi updates.  Of course, Delphi 10 Seattle Update 1 is out.  It even includes a few new features.  It is available for all people on Update Subscription.  (For those of you complaining about this, I hate to say it, but you were given plenty of warning and opportunities to get on board.)  Dr. Bob reports on two hot fixes that are also available.
  • It looks like I’m going to be speaking in Denmark in April at DAPUG’s annual conference.  I have spoken twice before, and have always enjoyed my trips there, and the fine hospitality provided by Jens Fudge and his family.  I’m looking forward to speaking there again.  Not 100% sure what the topics will be yet, but I promise it will be interesting.
  • I had a great time at EKON 19 – you should attend next year no matter where you are in the world – and the thing I enjoyed the most was my three hour seminar on Dependency Injection.  I covered Dependency Injection in Coding in Delphi,  but things have changed in the mean time, and there have been additions to the Spring for Delphi framework that make things even more powerful and capable.  So much so, in fact, that I’ve decided to write a book entitled Dependency Injection in Delphi. It will very likely be shorter than my other two books, and I think to start I’ll sell it as an ebook only (MOBI, ePub, and PDF) on Leanpub.  It will, however, go into Dependency Injection much more in depth than my two chapters in Coding in Delphi.   In any event, you can follow this link and sign up for updates about  the book and let me know how much you think I should charge for it.  There’s absolutely no time table on this – as you saw above, I have a lot of preparation to do for DAPUG – but I will be working on it.  I’ll go with “it will be available later this year”.  Again, I’m humbled and grateful by all the people who have bought my books.  

Registering Primitives in the Spring Container

I just got back from attending EKON 19 in Köln, Germany. I had a really good time and learned a lot. In fact, I learned the most in one of the sessions I gave – a three hour workshop on Dependency Injection.  Stefan Glienke was there – he maintains and enhances the Spring Framework – and he showed me something that the Spring Container can do that I didn’t know it could do — resolve primitive values by name and an anonymous method.

Here’s how this works.  First, we’ll take a look at a simple class:

This is a simple class — so simple that I won’t bother showing you the implementation, which I know you can figure out.

What is cool, however, is that you can inject both Name and Age properties.  I’ll demo one as a constructor-injected parameter, and the other as a field-injected value.

First, we’ll register the Name property.  We’ll get the name property using the following function that gets the user’s Windows Name:

This is just a wrapper around the Windows API call GetUserName.  The real fun is here:

First, we register the TPerson class so that the container can resolve things for it. Then we register a string with the name ‘name’, and delegate its “construction” to an anonymous function that calls our GetLocalUserName function. The point here is that we now have a “handle” – the string ‘name’ – to a string value that can resolve at runtime. We do the very same thing for the FAge field. That might seem like over-controlling things, but in effect it is quite powerful.  We can use it to ensure that both interface and primitive values in a class are resolved with the Container.  Imagine a constructor that requires not only interface dependencies, but a string value as well.  You can let the container resolve the values for the entire class.

Now, all we need to do is to change the above class to have these attributes:

Now, the Name property of the TPerson class will automatically be filled with the Windows user name without actually writing any more code to make it do that. The FAge field will be set with our favorite number ’42’.

(The code for this application can be found here.)

Now, at this point I bet you are asking “Why would I do that?”

It does, on the surface, seem like a bit of overkill.  But, in the world of Dependency Injection, being able to resolve all the dependencies of a given class – interfaces, classes, and primitives  — is golden.  Not having to write code, and centralizing the resolution of constructor parameters, properties, and fields –no matter what the type — are very useful indeed.  Remember, the more you can decouple your code via the Container, the better.

And you don’t even need but the one call to the ServiceLocator.

Flotsam and Jetsam # 109

Flotsam and Jetsam #102

  • Wallace and Gromit run on Delphi.
  •  I of course want you to buy my book, but I have been doing research for my next book and am thus reading sections of Delphi XE2 Foundations.  I can’t recommend this book enough.  It’s a tour de force for Delphi and the RTL.  I know how hard it is to write a book, and I can’t imagine how much work this one took.  It’s excellent, and I highly recommend it (after you buy my book, of course….).  Don’t be put off by “XE2” in the title, this is a great book for all Delphi developers.  Kudos to Chris Rolliston.
  • I’ve never really gotten into Quora, but it seems like a pretty cool site which has somehow managed to produce quality questions and answers without all the spam and other nonsense that often attends such a site.  Here’s a Quora question about Delphi that many of you might like to answer and/or read about.
  • Yesterday, I tweeted the following:  “Of all the types of reviews out there, the  ‘I couldn’t understand it so it must really suck, 1 star’ reviews are my favorite.” In researching my book, I’ve been re-reading Dependency Injection in .NET
    by Mark Seemann.  I looked up the book on Amazon, and was astonished to find that someone had given this amazing and enlightening book a 1-star review.  Some people, I swear.  This review is more along the lines of what the book deserves.
  • Correction:  Apparently, it was Borland C++ 3.0 that was the big box with the handle.  Thanks for the correction from Jeroen Pluimers, who also found a picture. (You have to scroll down a bit, but it’s there…)
  • A Clarification:  Two points to make on my last post about subscriptions.  First, it wasn’t about EMBT, but rather the software industry in general. Second, the point wasn’t “Software subscriptions are great!”, but rather “The industry is moving to subscriptions, and here’s why”.  Many folks seemed to believe I was arguing the former.  Perhaps I was just inarticulate.  Sorry for any confusion.