Advanced Apex 3rd Edition – With Upgrade Pricing for All!

The third edition of Advanced Apex Programming is now available!

And have I got a deal for you!

I’ve often been asked by people, what’s new in this edition and is there any way to get a discount on upgrading? Now there is a lot new in this edition – with numerous changes throughout the book both in content and in recommended best practices. The chapter on asynchronous programming has been almost completely rewritten to address queueable Apex (yes, all of the previous best practices have been rendered obsolete), and there’s a new chapter on maintaining Apex.

But how do you offer upgrades on a book? It’s not like software, where people can register and updates can detect previous versions. Or SAAS applications where the upgrades come with your annual subscription.

Also, in previous years, Salesforce licensed a special printing for distribution at Dreamforce, which was great for Dreamforce attendees, but not so good for everyone else. This year timing and their budget didn’t allow for that.

Still, it’s the Dreamforce time of year, right? Good time to do something special.

So, I decided to do an experiment – and offer “upgrade” pricing to everyone.

For the next 90 days the eBook version will be available on Amazon Kindle through their Select program – at a price of 9.99  (or whatever the Kindle select pricing is where you are). Prime customers will be able to borrow it. Kindle unlimited customers can just download it. After 90 days, it will revert to the normal $34.99 or equivalent price (unless the experiment is so successful that it makes more sense to extend the deal).

Books are a lot more limiting – I don’t have the same flexibility I have with the EBook. But there is one channel where I do have the ability to offer a great discount. So for those of you who want a new printed copy, I can do this – if you go to the book’s store on createspace, you can get a 50% discount by entering this code on checkout CDUK54Z5 – 50% off the regular price of $39.95.  Keep in mind, this code ONLY works on that store, and yes, they can ship internationally. This offer, which is sponsored in part by Full Circle Insights (which you should check out for our great marketing analytic tools), is good for 30 days, after which it too can go away at any time.

So that’s the deal. No free books at Dreamforce, but upgrade pricing for everyone for a limited time. Hopefully this approach will be more fair, and still provide a reasonable return (because I have to tell you – it was a lot of work!)

Purchase the print version with upgrade pricing – Use code CDUK54Z5 on checkout for the discount.

Purchase the Kindle version with upgrade pricing: (US) (Australia) (Brazil) (France) (Germany) (India) (Italy) (Japan) (Mexico) (Netherlands) (Spain) (UK)

(note, it may take a few days for the printed edition of the book to appear on some international Amazon sites – I’ll update the home page as I see them become available)


Summer 14 Describe Patterns

On each release, developers eagerly look through the release notes for exciting new features. I’ve found that the things that excite me most often aren’t the same things that thrill others. I often get most excited about small changes – sometimes they can have a huge impact on software design patterns.

This summer, the biggest feature for me is the elimination of Describe limits. This eliminates a huge Catch-22 when developing on the platform. On one hand, good Apex code is supposed to respect field level and object security. But the previous Describe statement limit made it difficult and sometimes impossible to do so on larger applications and systems, where the number of fields processed in an execution context could easily exceed the available limits.

The elimination of Describe limits does, however, raise an interesting question. How does this change impact design patterns and could other limits come into play? Or put another way – how costly are Describe calls in terms of CPU time?

Prior to now, the best design pattern for using Describe statements involved caching each Describe call so that you could at least ensure that you don’t call getDescribe on a field more than once in an execution context. The design pattern looked something like the getDescribeInfo function below, where the parameters are the field name and SObjectField token for the desired field:

private static Map<String, Schema.DescribeFieldResult> fieldDescribeCache = new Map<String, Schema.DescribeFieldResult>();
private static Schema.DescribeFieldResult getDescribeInfo(String name, SObjectField token)
    if(!fieldDescribeCache.containsKey(name)) fieldDescribeCache.put(name, token.getDescribe());
    return fieldDescribeCache.get(name);

Does it still make sense to use this kind of pattern? Or should you just call getDescribe() whenever you need describe information?

To find out, I did some benchmarking using the techniques described in chapter 3 of the second edition of Advanced Apex Programming.

I found that the approximate cost of a Describe statement is about 3 microseconds. This looked pretty fast to me. Can the earlier design pattern, with its cost of an additional function call and map lookup, be any faster?

The answer, as it turns out, is no. The overhead of caching and looking up data exceeded any benefits that might have come from avoiding the extra Describe calls.

Further testing showed the same results with SObject describes as field describes.

I don’t know if Describe calls on summer 14 are fast because work went in to optimize them, or because the platform is now caching describe data internally for you, but it doesn’t really matter. It seems clear that going forward, the optimal design pattern for describe statements is to use them inline as needed.

New Course Teaches Data Visualization Using the Salesforce Platform

I’m pleased to announce my latest Pluralsight course “Data Visualization for Developers”. This is not a course on – but in some ways it’s even better. It teaches the principles and practice of data visualization using as an underlying technology.

The course is published on Free trials are available if you are not already a subscriber.

Find out more in this preview video:


Advanced Apex 2nd Edition Available!

I’m pleased to announce the immediate availability of the second edition of Advanced Apex Programming for and

A few months ago, when SFDC announced the elimination of script limits, I knew that it had finally happened – a change that really impacted some of the content of the book. That led to some major changes in chapter three. And I figured, as long as I’m working on the book anyway; why not add a few more changes?

Chapter 6 extends the discussion on triggers to clarify some points based on questions I’ve received over the past year.

Chapter 7 has significant new content on batch apex and scheduled apex asynchronous patterns

Chapter 8 is a new chapter on concurrency issues (the later chapters have been renumbered).

Plus, there are numerous other smaller changes and additions scattered throughout the book.

All told, the book has grown by about 50 pages.

It also has a snazzy new cover – making it easy to determine going forward which edition you’re looking at.

Also, unlike last year, I’m pleased to announce that the Kindle and Nook editions are also available for those of you who prefer the eBook format.

The book available now on several country sites, and I’ll be linking the others as they go live. The links on the left will take you to the new edition – it will take a few weeks before all of the channel databases are updated.

Dreamforce 2013 Sessions

I’ve been so busy for the past month that I haven’t had much time to post, but I’m pleased to say that I’ll be presenting three sessions at Dreamforce this year.

Monday at 11:15am, Moscone West -2009, High Reliability DML and Concurrency Design Patterns for Apex

It’s remarkable when you think about it, that even though is a highly scalable multi-user and multithreaded system, there is hardly any documentation on how to deal with Apex concurrency issues. I’m looking forward to shining some more light on this topic and sharing some of my own adventures (and misadventures).

Monday at 1:30pm, Hilton San Francisco Union Square – Community Success Zone Theater, Apex Design Patterns for Managed Packages

This one is for the ISV’s in the community, particularly the developers. Those of us who create managed packages are a growing minority – it’s nice to see us getting some more attention this year!

Tuesday at 5:15pm, Moscone West – 2024, Design Patterns for Asynchronous Apex

At first I was thinking – 5:15pm before the gala? Talk about bad timing. But then again, talking about timing (good and bad) is a large part of asynchronous apex, and if the late hour gives you a syncing feeling, so much the better 🙂

I hope to see many of you there. Also, be sure to attend the developer keynote on Wednesday 10:30 at Moscone South – Gateway.

And, I encourage you to visit this site sometime this weekend for another post that you may find of interest.


New course: for .NET Developers

I’m pleased to announce my latest Pluralsight course “ for .NET Developers”. This course is a prequel to my course “ and Apex Fundamentals for Developers” intended specifically for .NET developers who are curious about

Here’s how I describe the course: is a unique cloud development platform that is in many ways different from traditional software development platforms – even those based on cloud technologies. This short course is designed specifically for .NET developers to understand the nature of by comparing and translating .NET concepts to their equivalents.

If you are a .NET developer, I encourage you to check it out – if you’re not already a Pluralsight subscriber, they have a free trial available (see right sidebar for link).