Facebook

Introduction

This book is not a rehash of the Salesforce Apex language documentation.

I just wanted to get that out of the way. I know there is sometimes value in the kind of book where 90% of the content is a rephrasing of the documentation and only 10% is new and interesting – a good author can organize information to make it easier for beginners to learn. But they are frustrating for intermediate and advanced developers who have to sift endlessly through familiar content to find one or two nuggets of new material.

So I’m going to assume that you either have read, or can read, the Force.com Apex language documentation. If you are new to Apex, you will find this book helpful – especially if you are coming to Apex from another language, but it is not a tutorial and will not replace the Apex documentation. If you have Apex programming experience, I’m confident you’ll find material here that will at the very least prove thought provoking, if not occasionally mind-blowing.

This book is about design patterns, best practices, and creative solutions to the kinds of problems developers face out in the real world.

You see, language documentation is generally written by the language team (or their technical writers) – which is good, because they know the language best. But the language team members are rarely application developers – that’s not their job.

White-papers and application notes are generally written by technical evangelists and consultants who often do have real-world experience, but are limited by the focus and format of the particular white paper or article. Short articles (of which I’ve written many) serve a purpose, but are often limited in the level of depth they can achieve.

If you want to bring together real-world experience in a format that allows for as much depth as necessary, and organizes the information in such a way that concepts build on each other to really teach the material – you need a book. You need a book written by someone who actually writes production code, both as a consultant for individual clients, and as a developer of applications for distribution.

Which brings me to the story how I came to write this book.

For most of my career, I was a developer on Microsoft platforms – proficient in C and C++, Visual Basic, VB .NET and C#. I ran (and still run) the company Desaware, that publishes a software licensing system for .NET (desaware.com) and now publishes my books (desawarepublishing.com). I also wrote a number of programming books, and spent quite a few years on the speaker circuit – presenting at conferences that focused on Microsoft technologies.

About eight years ago, a Salesforce consultant I know needed an Apex trigger written, and since I was one of the few programmers she knew, she asked me to take a look. Writing that first trigger was certainly easy enough – though I suspect I’d be embarrassed by the code if I looked at it now. I found myself spending more and more time working in Apex – I found it to be both challenging and fun.

About five years ago, I joined her and two others to establish a new company, Full Circle Insights, to develop a new Salesforce application related to marketing and sales data and analytics. Visit fullcircleinsights.com if you’re curious about the details. As CTO, I designed and built the application – which evolved into a very large and sophisticated native AppExchange app (an app that runs entirely on the Force.com platform). In doing so, I learned a lot.

As I have always enjoyed sharing what I learn, I ended up writing this book. It contains all of the things that I wish I had known eight years ago when I first started working in Apex. Things that I learned the hard way. Things that are either not found in the documentation, or are hidden in a footnote somewhere when they should be plastered across an entire page in bold flashing neon.

Think of this as a companion to the Apex Language reference – a commentary if you will. The focus is on the core language and design patterns. These are the essential foundations that you need to work effectively in Apex with the various platform features such as Lightning, VisualForce, Chatter, and so forth (topics that are important, and deserving of their own books, but are not covered here).

Parts of this book focus on concepts – ways of thinking that will be fairly easy to follow, even for relative beginners and those completely new to Apex. But parts of this book focus more on advanced design patterns, and to really understand them, you’ll need to dig into the code, and preferably install and experiment with the samples. You may need to refer back to the language documentation. You may even find parts of the book to be too hard to follow on a first reading. In truth, the book would hardly deserve the word “Advanced” in the title if this were not the case. If you do find yourself getting stuck, skip or scan a section and then move on. You’ll find it easier to digest the second time through.

By the time you’re done, I think you will find it was well worth the effort.

Dan Appleman

dan AT desawarepublishing DOT com