Reader small image

You're reading from  Apex Design Patterns

Product typeBook
Published inApr 2016
Reading LevelBeginner
Publisher
ISBN-139781782173656
Edition1st Edition
Languages
Right arrow
Authors (2):
Anshul Verma
Anshul Verma
author image
Anshul Verma

Anshul Verma has been working on the Salesforce platform since 2006. Prior to that, he has done extensive development using MS technologies on web, desktop, and mobile applications. He possesses a tremendous understanding of enterprise-scale systems and has worked in designing intricate systems with high scalability, performance, and robustness. He has been a Dreamforce speaker and is a regular contributor to Stack Exchange and other developer communities. He has four Salesforce certifications and is currently working as a project manager and technical architect where he is responsible for managing customer success and delivering high-quality solutions to his clients. He has conducted various training sessions in his current organization and trained over 50 new hires. He is very popular with his training batches and can be often found sharing his knowledge with his team and peers. He owns and maintains his blog (http://mightycoder.blogspot.com/), and you can follow him on Twitter at @toanshulverma.
Read more about Anshul Verma

Jitendra Zaa
Jitendra Zaa
author image
Jitendra Zaa

Jitendra Zaa has been working on the Salesforce platform since 2008. He has extensively worked on Java and .NET-based enterprise applications. He also has experience in working with multiple JavaScript libraries, web frameworks, ETL tools, and databases. He is an expert in designing and implementing integrations of Salesforce with external systems. He is a regular speaker at the worlds biggest developer event, Dreamforce, mostly in developer track. Because of his contributions to the Salesforce community, he has also been awarded the Salesforce MVP title. He has more than eight Salesforce certifications and works as a Salesforce technical architect. He owns one of the most viewed Salesforce developer blogs (http://www.JitendraZaa.com), formerly, http://Shivasoft.in. You can follow him on Twitter at @JitendraZaa.
Read more about Jitendra Zaa

View More author details
Right arrow

Preface

It was spring 2015; we were both discussing our presentation for Dreamforce 2015. During the discussion, we stumbled on the topic of the usage of design patterns in Apex. We observed that design patterns are still not extensively used in the Apex programming arena. We think that a few prominent factors for this situation are that there are not enough resources available around the design pattern implementation in Apex. Secondly, most of the Apex programmers who started their development career with Force.com have less exposure to other development platforms. Thirdly, some of the design patterns simply do not apply to Force.com development platforms.

As per our observation, the usage and mention of design patterns in day-to-day programming is reduced in Apex as compared to other development platforms. Developers coming from other programming backgrounds mostly have a working experience with design patterns and it's implicit for them to use it in their code style and design.

We realized that it would be even better to develop content around the design pattern implementation in a language that Apex developers can easily relate to. We positively think that by providing scenarios that are specific to Apex development use cases, developers will be able to understand and implement the design patterns in Apex with ease.

To ensure that we are able to provide information uniformly to all Apex developers irrespective of their experience level, this book also includes general programming best practices, programming principles, OOP concepts, and the usual pitfalls at appropriate places.

In line with our past experience with design pattern learning and implementation is the problem of memorizing the design patterns and situations where they fit in. However, in this book, we took real-life scenarios to explain a situation where an appropriate design pattern will be applied. One can easily relate the design pattern with an example given in this book to identify when it is the time to use that pattern.

Some open source GitHub repository links, Salesforce official developer blogs, and other tips have been shared throughout the book, which can be very helpful in Force.com project development.

What this book covers

Chapter 1, An Introduction to Apex Design Pattern, covers the basics of inheritance, abstract classes, polymorphism, cohesion and coupling, and object-oriented design principles.

Chapter 2, Creational Patterns, focuses on different ways to instantiate objects to achieve code reusability, ease of maintenance, and loose coupling.

Chapter 3, Structural Patterns, explains the design patterns that can solve many situations and problems, which occur during project development in Apex, that demand a change in functionalities and cause a ripple effect on the rest of the system.

Chapter 4, Behavioral Patterns, provides a glimpse of some problems, such as double dispatch and code maintenance issues, and explains how to use appropriate design patterns to fix them.

Chapter 5, Handling Concurrency in Apex, discusses the design solution for the race condition in concurrency, which can result in data corruption without anyone noticing it.

Chapter 6, Anti-patterns and Best Practices, shows some common pitfalls observed during application development in Apex and suggested solutions.

What you need for this book

We need an Internet-enabled computer that is capable of running modern browsers supported by Salesforce. We can use the developer console in a browser to write the Apex code in Salesforce.

Interested readers can also use their favorite IDEs, such as Sublime Text, Eclipse, Welkins, Atom, Aside, Cloud9, or BrainEngine.

You will also need a free Salesforce developer account to try all the code snippets and examples provided in this book.

Who this book is for

This book is intended for all Apex developers who want to learn and enhance their Apex code designing skills by applying various design patterns. It can be considered as a stepping stone for beginners or intermediate-level Apex programmers by filling their arsenal with powerful design patterns.

Conventions

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

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "The AdminGoldSupportImpl and AdminPlatinumSupportImpl classes are written in the same way."

A block of code is set as follows:

public class Mario {
    public void ability(){
        System.debug('I can Walk');
    }
    public void info(){
        System.debug('I am Mario');
    }
}

Any command-line input or output is written as follows:

$ mkdir css
$ cd css

New terms and important words are shown in bold. 

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

For this book we have outlined the shortcuts for the Mac OX platform if you are using the Windows version you can find the relevant shortcuts on the WebStorm help page https://www.jetbrains.com/webstorm/help/keyboard-shortcuts-by-category.html.

Reader feedback

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

To send us general feedback, simply e-mail , and mention the book's title in 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 at www.packtpub.com/authors.

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 this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.
  2. Hover the mouse pointer on the SUPPORT tab at the top.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box.
  5. Select the book for which you're looking to download the code files.
  6. Choose from the drop-down menu where you purchased this book from.
  7. Click on Code Download.
You can also download the code files by clicking on the Code Files button on the book's webpage at the Packt Publishing website. This page can be accessed by entering the book's name in the Search box. Please note that you need to be logged in to your Packt account.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows
  • Zipeg / iZip / UnRarX for Mac
  • 7-Zip / PeaZip for Linux

Downloading the color images of this book 

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/ApexDesignPatterns_ColorImages.pdf.

Errata

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 could 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 http://www.packtpub.com/submit-errata, 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 to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted 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.

Questions

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Apex Design Patterns
Published in: Apr 2016Publisher: ISBN-13: 9781782173656
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (2)

author image
Anshul Verma

Anshul Verma has been working on the Salesforce platform since 2006. Prior to that, he has done extensive development using MS technologies on web, desktop, and mobile applications. He possesses a tremendous understanding of enterprise-scale systems and has worked in designing intricate systems with high scalability, performance, and robustness. He has been a Dreamforce speaker and is a regular contributor to Stack Exchange and other developer communities. He has four Salesforce certifications and is currently working as a project manager and technical architect where he is responsible for managing customer success and delivering high-quality solutions to his clients. He has conducted various training sessions in his current organization and trained over 50 new hires. He is very popular with his training batches and can be often found sharing his knowledge with his team and peers. He owns and maintains his blog (http://mightycoder.blogspot.com/), and you can follow him on Twitter at @toanshulverma.
Read more about Anshul Verma

author image
Jitendra Zaa

Jitendra Zaa has been working on the Salesforce platform since 2008. He has extensively worked on Java and .NET-based enterprise applications. He also has experience in working with multiple JavaScript libraries, web frameworks, ETL tools, and databases. He is an expert in designing and implementing integrations of Salesforce with external systems. He is a regular speaker at the worlds biggest developer event, Dreamforce, mostly in developer track. Because of his contributions to the Salesforce community, he has also been awarded the Salesforce MVP title. He has more than eight Salesforce certifications and works as a Salesforce technical architect. He owns one of the most viewed Salesforce developer blogs (http://www.JitendraZaa.com), formerly, http://Shivasoft.in. You can follow him on Twitter at @JitendraZaa.
Read more about Jitendra Zaa