Book Image

Mastering Application Development with

By : Kevin J. Poorman
Book Image

Mastering Application Development with

By: Kevin J. Poorman

Overview of this book is an extremely powerful, scalable, and secure cloud platform, delivering a complete technology stack, ranging from databases and security to workflow and the user interface. With's cloud platform, you can build any business application and run it on your servers. The book will help you enhance your skillset and develop complex applications using It gets you started with a quick refresher of's development tools and methodologies, and moves to an in-depth discussion of triggers, bulkification, DML order of operations, and trigger frameworks. Next, you will learn to use batchable and schedulable interfaces to process massive amounts of information asynchronously. You will also be introduced to Salesforce Lightning and cover components—including backend (apex) controllers, frontend (JavaScript) controllers, events, and attributes—in detail. Moving on, the book will focus on testing various apex components: what to test, when to write the tests, and—most importantly—how to test. Next, you will develop a changeset and use it to migrate your code from one org to another, and learn what other tools are out there for deploying metadata. You will also use command-line tools to authenticate and access the Rest sObject API and the Bulk sObject API; additionally, you will write a custom Rest endpoint, and learn how to structure a project so that multiple developers can work independently of each other without causing metadata conflicts. Finally, you will take an in-depth look at the overarching best practices for architecture (structure) and engineering (code) applications on the platform.
Table of Contents (16 chapters)
Mastering Application Development with
About the Author
About the Reviewers

Preface's platform is one of the most exciting and unique development platforms for business applications. A lot of Salesforce development can be done declaratively without writing code, but to truly master the platform, you'll need to be able to develop not only declaratively, but also with code. Ultimately, you will need to know when to use which toolset—declarative or code.

It is relatively easy, in a world with Salesforce developer forums, Stack Overflow, and user groups, to find others who have faced the same issues you're facing. As a developer, it's likely that you can cobble together a solution from posted solutions. Understanding and tweaking those posts into a solution for your particular problem, however, requires a greater mastery of the platform.

This book is all about mastering the platform; taking your skills as a developer and tuning them for the unique features of the Salesforce platform. We'll discuss the architecture and code and which tool to use for the job. It's going to be awesome. So let's get started…

What this book covers

Chapter 1, A Conceptual Overview of Application Development on the Salesforce1 Platform, is a quick refresher of the development tools and methodologies. We'll discuss the concepts of classes, triggers, and unit testing that we'll be mastering in the further chapters.

Chapter 2, Architecting Sustainable Triggers Using a Trigger Framework, will dive deep into why you would need a trigger, when you should and should not use a trigger, and how to architect triggers for maintainability. Additionally, we'll dig into trigger frameworks that provide cleaner, more scalable solutions that solve many of the problems that plague traditional trigger development.

Chapter 3, Asynchronous Apex for Fun and Profit, is all about Apex classes that implement the batchable, scheduleable, and queueable interfaces as well as the @future method Annotation.

Chapter 4, Lightning Concepts, discusses the four new features of the Salesforce platform that carry the Lightning moniker. We'll start with Lightning connect and move on to cover process builder, app builder, and lightning components.

Chapter 5, Writing Efficient and Useful Unit Tests, talks about unit testing, which is the single most important activity an application developer has to master. However, writing unit tests is rarely seen as exciting. In this chapter, we'll look at how to write useful unit tests that help us maintain our application over time.

Chapter 6, Deploying Your Code, takes you to the next step—you've written and tested your code, now what? This chapter is a tour of the many ways to deploy your application metadata from one org to another. Specifically, we'll cover the Ant migration toolkit, IDE deployment, and Change sets. Additionally, we'll briefly touch on packaging as a means of deploying metadata.

Chapter 7, Using, Extending, and Creating API Integrations, demonstrates how to use the sObject and bulk APIs provided by Salesforce as well as how to create your own custom REST endpoints with Apex. Finally, we'll build out a set of classes to make calling external REST APIs as painless as possible.

Chapter 8, Team Development with the Salesforce1 Platform, discusses and works through the pitfalls of team development in general and the unique solutions available to us on the Salesforce1 Platform.

Chapter 9, My Way—A Prescriptive Discussion of Application Development on Salesforce1, looks at overarching best practices for Architecture and Engineering of applications on the platform in depth. Specifically, we discuss the nature of keeping things simple, testing things well, naming things intuitively, and writing maintainable code. While the rest of the book has been descriptive of the best practices, this chapter is an opinionated prescription for developing Salesforce1 applications.

What you need for this book

All you need to get the most out of this book is your brain, your computer with a modern web browser, and a free Salesforce developer org. You can sign up for a free developer org at Of course other tools can help, but they aren't required. Optional tools include Sublime Text 3 (with the MavensMate plugin), Atom (with the MavensMate plugin), and Intellij (with the Illuminated Cloud plugin). Again, these are all completely optional. In later chapters, we'll discuss some JavaScript-related tools but we'll discuss installing them when we get there.

Who this book is for

This book is for Salesforce developers. The more you know about Apex, the more you'll take away from this book. Hopefully, as you master more and more of the platform, you'll be able to revisit this book and take away more each time. Regardless of how much Apex you know, this book can teach us all something about how to master the platform.


In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code, and code mixed in with text are shown as follows: A block of code is set as follows:

public class AccountTriggerHandler extends triggerHandler {
  public override void beforeInsert() {

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

global void execute(Database.BatchableContext BC, List<Account> scope) {
  List<Account> toDelete = new List<Account>();
  List<Account> toUpdate = new List<Account>();
  for (Account a : scope) {
    } else {

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Another tab in the bottom pane is the Tests tab."


Warnings or important notes appear in a box like this.


Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.


Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from


Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.


You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.