35,99 €
Salesforce makes architecting enterprise grade applications easy and secure – but you'll need guidance to leverage its full capabilities and deliver top-notch products for your customers.
This fourth edition brings practical guidance to the table, taking you on a journey through building and shipping enterprise-grade apps.
This guide will teach you advanced application architectural design patterns such as separation of concerns, unit testing, and dependency injection. You'll also get to grips with Apex and fflib, create scalable services with Java, Node.js, and other languages using Salesforce Functions and Heroku, and find new ways to test Lightning UIs. These key topics, alongside a new chapter on exploring asynchronous processing features, are unique to this edition. You'll also benefit from an extensive case study based on how the Salesforce Platform delivers solutions.
By the end of this Salesforce book, whether you are looking to publish the next amazing application on AppExchange or build packaged applications for your organization, you will be prepared with the latest innovations on the platform.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 1024
Veröffentlichungsjahr: 2023
Salesforce Platform Enterprise Architecture
Fourth Edition
A must-read guide to help you architect and deliver packaged applications for enterprise needs
Andrew Fawcett
BIRMINGHAM—MUMBAI
Salesforce Platform Enterprise Architecture
Fourth Edition
Copyright © 2023 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Senior Publishing Product Manager: Ashitosh Gupta
Acquisition Editor – Peer Reviews: Gaurav Gavas
Project Editor: Amisha Vathare
Content Development Editor: Matthew Davies
Copy Editor: Safis Editing
Technical Editor: Srishty Bhardwaj
Proofreader: Safis Editing
Indexer: Subalakshmi Govindhan
Presentation Designer: Pranit Padwal
Developer Relations Marketing Executive: Rohan Dobhal
First published: September 2014
Second edition: March 2017
Third edition: November 2019
Fourth edition: March 2023
Production reference: 2060423
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-80461-977-3
www.packt.com
I’ve had a lifelong passion for software, starting as a young child with TRS-80 Model III’s typing in BASIC code from paper books, making games in HyperCard scripting on a Macintosh Classic, building and running Bulletin Board Systems (BBSes) before the internet was popular, and working on virtually all types of hardware and software throughout my teenage and college years. In 2009 I pivoted to building primarily on Salesforce to break into what was then the crazy frontier of cloud computing. I’m now one of the most certified Salesforce professionals out there, a Salesforce MVP Hall of Fame member, and have traveled the world sharing knowledge and meeting people. It has been one heck of an adventure!
Yes, the Salesforce platform is incredible, but the people that make up the Salesforce community take the technology to a whole other level. The solving of each other’s problems, and the relationships that are created are Salesforce’s X factor in my opinion. Within the Salesforce community, the name Andy Fawcett stands out as the one of the greats. I first came to know Andy from his blog over a decade ago. When googling for how to solve a problem on the platform, his articles would come up regularly. His thought leadership left a strong impression on me, and I always looked up to him for this. Andy was the first to solve hard problem after hard problem, year after year, while sharing those lessons back out for the rest of us to benefit from.
There have been several chapters of my career which involve Andy, but one that’s particularly memorable were the years where I was working at Kenandy and Andrew was at FinancialForce. We had common challenges as both of our products were some of the most complex offerings on the AppExchange and both played in the ERP space. We had hundreds of Custom Objects with sometimes hundreds of fields per object, millions of lines of code powering extremely complex business processes, bespoke user interfaces which went beyond the limits of Visualforce and Lightning, custom DevOps and packaging techniques that brought the platform to its knees, and huge development teams working around the clock. It was during this time I found out about Andy’s original Force.com Enterprise Architecture book launching and quickly shared it with our development team. We had copies sitting on our desks for reference and inspiration. The concepts in the book are best practices for apps of any size, but for enterprise apps they are table stakes.
Over the years Andy and I have shared the limelight at conferences and meetups together, attended each other’s talks, and collaborated in workshops and other events – we’ve even enjoyed a whiskey or two together! I love the fact that Andy now works at Salesforce. One of his superpowers is that he brings his years of outsider knowledge of building on the platform to the inside, where he can drive change for the customers and partners that he has first-hand empathy for. He’s like that instructor you may have had, that actually had real-world experience, and wasn’t just reciting theory.
As in other areas of relatively new and evolving tech, Salesforce doesn’t have enough seasoned architectural talent to go around. This book is key to helping to create the next generation of world-class software practitioners. The concepts outlined here can be used to create Salesforce software for the next billion-dollar company and beyond. I’m so happy to see a fourth edition of this book being released to include the current iteration of the platform.
It is an incredible honor to be asked by Andy to write this foreword. May the knowledge in this book be an accelerator for you to build incredible software. And don’t forget, you, too, are a source of inspiration for others with every step of your journey!
Daniel J. Peter
Salesforce Practice Lead at Robots & Pencils
Andrew Fawcett is a product management executive with a strong engineering background. With over 30 years of experience, he has held various roles, covering coding, architecture, tooling, benchmarking, and platform design. Currently, he is the VP of Product Management at Salesforce and holds the Salesforce Certified Platform Developer II certification. He leads product development for Heroku and Functions, blogs, contributes to open source, and has public-speaking experience. His interests include retro computing, amateur electronics, and LEGO collecting.
I owe a debt of gratitude to my wife Sarah and our French bulldog Lilo for their unwavering support as I authored this book and led product development at Heroku. Many thanks to foreword writer, reviewers, and friends Daniel Peter, Seb Costanzo, John M. Daniel, and Arvind Narsimhan for their valuable input. And a special thank you to Salesforce for providing technology that has helped shape so many careers, including mine.
John M. Daniel has been working in the technology sector for over 20 years. During that time, he has worked with a variety of technologies and in various project roles. Currently, he serves as the Senior Director of Digital Platforms at Steampunk; a Salesforce Partner and Change Agent in the Federal contracting industry. He holds multiple Salesforce certifications. He is currently working toward becoming a Certified Technical Architect. He loves to work on open-source projects such as Force-DI, AT4DX, and the DomainBuilder framework. He has been a technical reviewer for Mastering Salesforce DevOps, Learning Apex Programming, and Apex Design Patterns. He co-leads his local Salesforce Developers User Group and can be found on Twitter at @ImJohnMDaniel.
I would like to thank my wife, Allison, for always giving me the freedom to pursue my interests.
Sebastiano Costanzo is an ISV Technical Evangelist with expertise in Salesforce AppExchange technology partnerships. During his 15 years at Salesforce, he worked with Salesforce partners and customers around the world, helping them design and develop innovative solutions on the platform. He currently works with Salesforce consulting partners and customers as a Solution Architect, collaborating closely with them to deliver high-performing solutions aligned with their business objectives.
I am honored to have been asked by my former partner, colleague, mentor, and friend Andrew to review his book on Salesforce platform enterprise architecture.
I am grateful to my wife Kasia and daughter Karolina for their unwavering support while I worked on this book review. It was also a pleasure spending time with Andrew’s lovely wife Sarah and their famous French bulldog Lilo when we got together in the Bay Area. Thank you all for being there for me every step of the way.
Arvind Narsimhan has over 25 years of experience in building software, specializing in enterprise integration. He presently works for Salesforce, assisting enterprise customers with Salesforce implementations, focusing on the integration strategy, build, and deployment using MuleSoft, Java, and public cloud technologies.
Enterprise organizations have complex processes and integration requirements that typically span multiple locations around the world. They seek out the best-in-class applications that support not only their current needs, but also those of the future. The ability to adapt an application to their practices, terminology, and integrations with other existing applications or processes is key for them. They invest as much in your application as they do in you, as the vendor or developer capable of delivering an application strategy that will grow with them.
Throughout this book, you will be shown how to architect and support enduring applications for enterprise scale businesses using Salesforce by exploring how to identify architecture needs and design solutions based on industry-standard patterns.
Large-scale applications require careful coding practices to keep the code base scalable. You’ll learn advanced coding patterns based on industry-standard enterprise patterns and reconceive them for the Salesforce Platform, allowing you to get the most out of the platform and incorporate best practices from the start of your project.
As your development team grows, managing the development cycle with more robust application life cycle tools, and using approaches such as Continuous Integration, become increasingly important. There are many ways to build solutions on the Salesforce Platform; this book cuts a logical path through the steps and considerations for building packaged solutions from start to finish, covering all aspects from engineering to getting it into the hands of your target users and beyond, ensuring that they get the best value possible from your Salesforce Platform application.
This book is aimed at Salesforce Platform developers who are looking to push past Salesforce Platform basics and learn how to truly discover its potential. You will find this book handy if you are looking to expand your knowledge of developing complex, scalable applications for use in enterprise businesses with the Salesforce Platform. This book will enable you to know your way around Salesforce Platform’s non-programmatic functionality as well as how to use Apex, Node.js, Java, and other languages and aid you in learning how to architect powerful solutions for enterprise-scale demands. If you have a background in developing inside other enterprise software ecosystems, you will find this book an invaluable resource for adopting the Salesforce Platform.
Chapter 1, Building and Publishing Your Application, gets your application out to your prospects and customers using packages, AppExchange, and subscriber’s support.
Chapter 2, Leveraging Platform Features, ensures that your application is aligned with the platform features and uses them whenever possible, which is great for productivity when building your application, but—perhaps more importantly—it ensures that your customers are also able to extend and integrate with your application further.
Chapter 3, Application Storage, teaches you how to model your application’s data to make effective use of storage space, which can make a big difference to your customer’s ongoing costs and initial decision making when choosing your application.
Chapter 4, Apex Execution and Separation of Concerns, explains how the platform handles requests and at what point Apex code is invoked. It is important to understand how to design your code for maximum reuse and durability.
Chapter 5, Application Service Layer, focuses on understanding the real heart of your application: how to design it, make it durable, and future proof it around a rapidly evolving platform using Martin Fowler’s Service pattern as a template.
Chapter 6, Application Domain Layer, aligns Apex code typically locked away in Apex Triggers into classes more aligned with the functional purpose and behavior of your objects, using object-orientated programming (OOP) to increase reuse and streamline code and leverage Martin Fowler’s Domain pattern as a template.
Chapter 7, Application Selector Layer, leverages SOQL to make the most out of the query engine, which can make queries complex. Using Martin Fowler’s Mapping pattern as a template, this chapter illustrates a means to encapsulate queries, making them more accessible and reusable, and making their results more predictable and robust across your code base.
Chapter 8, Additional Languages, Compute, and Data Services, explores how to build application backend logic that references the Service layer pattern without using the Apex programming language. This will enable you to use your skills with other languages for application development, which frees you from Apex heap and CPU limits.
Chapter 9, Building User Interfaces, covers the concerns of an enterprise application user interface with respect to translation, localization, and customization, as well as the pros and cons of the various UI options available in the platform.
Chapter 10, User Interfaces and the Lightning Component Framework, explains the architecture of this modern framework for delivering rich client-device agnostic user experiences, from a basic application through to using component methodology to extend Lightning Experience and Salesforce1 Mobile.
Chapter 11, Providing Integration and Extensibility, explains how enterprise-scale applications require you to carefully consider integration with existing applications and business needs while looking to the future by designing the application with extensibility in mind.
Chapter 12, Asynchronous Processing and Big Data Volumes, shows that designing an application that processes massive volumes of data, either interactively or asynchronously, requires understanding your customer’s volume requirements and leveraging the latest platform tools and features, such as the query optimizer.
Chapter 13, Unit Testing, explores the differences and benefits of unit testing versus system testing. This aims to help you understand how to apply dependency injection and mocking techniques to write unit tests that cover more code scenarios and run faster. You will also look at leveraging practical examples of using the Apex Stub API with the ApexMocks open source library and testing client logic with the Jest open source library.
Chapter 14, Source Control and Continuous Integration, shows that maintaining a consistent code base across applications of scale requires careful consideration of source control and a planned approach to integration as the application is developed and implemented.
Chapter 15, Integrating with External Services, explores how you and your customers can extend your application securely with services and data hosted outside of the Salesforce Platform, using both code and configuration tools such as Flow.
Chapter 16, Adding AI with Einstein, explores services and features provided by Salesforce in order for you and your customers to add AI and machine learning capabilities to your application and its data.
In order to follow the practical examples in this book, you will need to install the Salesforce DX CLI and Salesforce Extensions for Visual Studio Code. You will also require access to a Salesforce Developer Edition org via https://developer.salesforce.com/ and a temporary Salesforce DevHub org via https://developer.salesforce.com/promotions/orgs/dx-signup.
The following is the list of the software requirements for this book:
Salesforce DevHub org trialSalesforce Developer Edition org (to register your test package namespace)Salesforce DX CLISalesforce Extensions for Visual StudioSalesforce Developer Console (partial usage as needed)GitHub Desktop clientAt the time of publication, Andrew Fawcett works as a VP for Product Management within Salesforce. The statements and opinions in this book are his own and not those of Salesforce.
The code bundle for the book is hosted on GitHub at https://github.com/PacktPublishing/Salesforce-Platform-Enterprise-Architecture-4th-Edition. There, you can find the sample code for each chapter on its own branch. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
We also provide a PDF file that has color images of the screenshots and diagrams used in this book. You can download it here: https://packt.link/PTWMq.
There are a number of text conventions used throughout this book.
CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. For example: “Using the sf deploy command it is possible to deploy Functions and the contents of the /source/formulaforce folder in one CLI command.”
A block of code is set as follows:
{"packageDirectories":[{"path":"force-app","package":"FormulaForce App","default":true}When we wish to draw your attention to a particular part of a code block, the relevant lines or items are highlighted:
"namespace":"fforce","sfdcLoginUrl":"https://login.salesforce.com","sourceApiVersion":"56.0","packageAliases":{"FormulaForce App":"0Ho6A000000CaVxSAK"}Any command-line input or output is written as follows:
sfdx force:org:openBold: Indicates a new term, an important word, or words that you see on the screen. For instance, words in menus or dialog boxes appear in the text like this. For example: “Select System info from the Administration panel.”
Warnings or important notes appear like this.
Tips and tricks appear like this.
Feedback from our readers is always welcome.
General feedback: Email [email protected] and mention the book’s title in the subject of your message. If you have questions about any aspect of this book, please email us at [email protected].
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you reported this to us. Please visit http://www.packtpub.com/submit-errata, click Submit Errata, and fill in the form.
Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit http://authors.packtpub.com.
Once you’ve read Salesforce Platform Enterprise Architecture, Fourth Edition, we’d love to hear your thoughts! Please click here to go straight to the Amazon review page for this book and share your feedback.
Your review is important to us and the tech community and will help us make sure we’re delivering excellent quality content.
Join our community’s Discord space for discussions with the author and other readers:
https://packt.link/businesscenter
Thanks for purchasing this book!
Do you like to read on the go but are unable to carry your print books everywhere? Is your eBook purchase not compatible with the device of your choice?
Don’t worry, now with every Packt book you get a DRM-free PDF version of that book at no cost.
Read anywhere, any place, on any device. Search, copy, and paste code from your favorite technical books directly into your application.
The perks don’t stop there, you can get exclusive access to discounts, newsletters, and great free content in your inbox daily
Follow these simple steps to get the benefits:
Scan the QR code or visit the link belowhttps://packt.link/free-ebook/9781804619773
Submit your proof of purchaseThat’s it! We’ll send your free PDF and other benefits to your email directlyPreface
Who this book is for
What this book covers
To get the most out of this book
Get in touch
Part I: Key Concepts for Application Development
Building and Publishing Your Application
Introducing Salesforce DX
Introducing the new Salesforce Task Driven CLI
Required organizations
Introducing Salesforce Hyperforce
Introducing the book’s sample application
Package types and benefits
The features and benefits of managed and unlocked packages
Creating your first managed package
Setting and registering your package namespace
Creating the package and assigning it to the namespace
Adding components to the package
Dependent packages
Package platform feature dependencies
Release and Beta packages
Optional package dependencies
Dynamic bindings
Dependent packages
Supporting package upgradability
Managing package ancestry
Developing in scratch orgs containing ancestry information
Becoming a Salesforce partner and the benefits of doing so
Security review and benefits
Creating test and demo orgs via the Environment Hub
Introduction to AppExchange and listings
Installing and testing your package
Automating package installation
Understanding how to license your package
The Licenses tab and managing customer licenses
The Feature Parameters tab and managing features
The Subscribers tab
The Subscriber Overview page
How licensing is enforced in the subscriber org
Providing support
Customer metrics
Trialforce and Test Drive
Distributing Salesforce Connected Apps
Summary
Leveraging Platform Features
Packaging and upgradable components
Custom Fields – picklist values
Global picklists
Automating upgrade tasks with the Metadata API
Understanding Custom Field features
Default field values
Encrypted fields
Special considerations for platform encryption
Lookup options, filters, and layouts
Rollup summaries and limits
Understanding the available security features
Functional security
Your code and security review considerations
Data security
Your code and security review considerations
Platform APIs
Considerations for working well with the platform’s APIs
Localization and translation
Localization
Translation
Building customizable user interfaces
Layouts
Customizing Lightning Components and Visualforce pages
Lightning App Builder and Components
Email customization with email templates
Flow
Social features and mobile
Creating and testing a new package version
Summary
Application Storage
Mapping out end user storage requirements
Understanding the different storage types
Data storage
Columns versus rows
Visualizing your object model
Considerations for configuration data
File storage
Record identification, uniqueness, and auto-numbering
Unique and external ID fields
Auto Number fields
Customizing the Auto Number display format
Record relationships
Reusing existing Standard Objects
Importing and exporting data
Salesforce CLI data import and export
Salesforce Data import wizard
Options for replicating data
External data sources
Connecting to AWS data sources
Creating a new FormulaForce package version
Summary
Apex Execution and Separation of Concerns
Execution contexts
Exploring execution contexts
Execution context and state
Platform Cache
Execution context and security
Execution context transaction management
Apex governors and namespaces
Namespaces and governor scope
Deterministic and non-deterministic governors
Key governors for Apex package developers
Where is Apex used?
Separation of concerns
Apex code evolution
Separating concerns in Apex
Separation of concerns in Lightning Components
Separation of concerns in Lighting Web Components
Separation of concerns in Lightning Aura Components
Execution context logic versus application logic concerns
Improving incremental code reuse
Patterns of Enterprise Application Architecture
The Service layer
The Domain layer
The Data Mapper (Selector) layer
Introducing the Apex Commons library
Unit testing versus system testing
Packaging the code
Summary
Part II: Backend Logic Patterns
Application Service Layer
Introducing the Service layer pattern
Implementation of design guidelines
Naming conventions
Bulkification
Security enforcement
Defining and passing data
Considerations when using SObject in the Service layer interface
Transaction management
Compound services
A quick guideline checklist
Handling DML with the Unit of Work pattern
Without a Unit of Work
With a Unit of Work
The Unit of Work scope
Unit Of Work special considerations
Services calling services
Contract-driven development
Testing the Service layer
Mocking the Service layer
Calling the Service layer
From Lightning Web Component Apex controllers
From Visualforce Apex controllers
From the Apex Scheduler
Updating the FormulaForce package
Summary
Application Domain Layer
Introducing the Domain layer pattern
Encapsulating an object’s behavior in code
Interpreting the Domain layer in Apex
Domain classes in Apex compared to other platforms
Implementing design guidelines
Naming conventions
Bulkification
Defining and passing data
Transaction management
Domain class template
Implementing Domain trigger logic
Routing trigger events to Domain class methods
Enforcing security
Default behavior of fflib_SObjectDomain
Changing the default object security behavior of fflib_SObjectDomain
Enabling user mode by default for fflib_SObjectUnitOfWork
Apex Trigger event handling
Defaulting field values on insert
Validation on insert
Validation on update
Implementing custom Domain logic
Object-oriented programming
Creating a compliance application framework
An Apex interface example
Step 5 – Defining a generic service
Step 6 – Implementing the Domain class interface
Step 7 – The Domain class Factory pattern
Step 8 – Implementing a generic service
Step 9 – Using the generic service from a generic controller
Summarizing the implementation of the compliance framework
Testing the Domain layer
Unit testing
Test Trigger methods using DML and SOQL
Test Trigger methods without using DML or SOQL
Test methods using the Domain class methods
Calling the Domain layer
Service layer interactions
Domain layer interactions
Updating the FormulaForce package
Summary
Application Selector Layer
Introducing the Selector layer pattern
Implementing design guidelines
Security conventions
Naming conventions
Bulkification
Record order consistency
Querying fields consistently with a Selector field contract
The Selector class template
Implementing the standard query logic
Standard features of the Selector base class
Enforcing security
Default behavior
Overriding the default behavior and enabling user mode
Knowing when to run SOQL queries in system mode
Ordering
Field Sets
Multi-Currency
Implementing custom query logic
A basic custom Selector method
A custom Selector method with sub-select
A custom Selector method with related fields
A custom Selector method with a custom dataset
Combining Apex data types with SObject types
SOSL and aggregate SOQL queries
Introducing the Selector factory
SelectorFactory methods
Writing tests and the Selector layer
Updating the FormulaForce package
Summary
Additional Languages, Compute, and Data Services
FormulaForce Web and API requirements
Applying Heroku
Expanding FormulaForce automation experiences
Applying Functions
Solution overview
Usage of the sample source code included in this chapter
Other general considerations
Building web experiences with Node.js and Heroku
Step 1: Understanding LWR Node.js source files
Step 2: Introduction to the Insights LWC and Insights API
Step 3: Starting the LWR server locally and editing code
Step 4: Deploying the LWR server to Heroku for the first time
Step 5: Adding storage for race predictions using Heroku Postgres
Step 6: Accessing season data using Heroku Connect
Step 7: Accessing partner data using the Salesforce API
Step 8: Deploying the website and API to end users
Building OpenAPI-enabled APIs with Heroku
Step 1: Understanding the API Node.js source files
Step 2: Extending the LWR server to support APIs
Step 3: Implementing FormulaForce partner authentication
Step 4: Introduction to OpenAPI and associating it with API code
Step 5: Overview of the Swagger-generated API documentation
Extending automation with Java and Salesforce Functions
Step 1: Understanding the Java Function source files
Step 2: Accessing org data with the Salesforce Functions SDK
Step 3: Running and editing the Function locally
Step 4: Deploying the Driver Check-in Function
Step 5: Invoking a deployed Function from Apex
Wrapping Functions and Heroku APIs in Apex Service classes
Step 1: Insights API and the Apex Service layer
Step 2: Driver Check-in Function and the Apex Service layer
Step 3: Exposing the Driver Check-in Function to Flow
Summary
Part III: Developing the Frontend
Building User Interfaces
What devices should you target?
Leveraging standard and custom UIs
Why consider Visualforce over the Lightning Component framework?
Lightning Component programming frameworks
Leveraging the Salesforce standard UIs and tools
Overriding standard Salesforce UI actions
Combining standard UIs with custom UIs
Embedding a custom UI into a standard UI
Reusing Salesforce UI components in a custom UI
Extending the Salesforce standard UIs
Lightning Components
Visualforce pages
Generating downloadable content
Generating printable content
Overriding the UI language
Client-server communication
Interacting with Apex and data
API governors and availability
Database transaction scope and client calls
Managing limits
Object and field level security
Enforcing security in LWC
Enforcing security in Visualforce
Managing performance and response times
Lightning tools to monitor size and response times
Using the Service layer and database access
Considerations for client-side logic and Service layer logic
Considerations for using third-party JavaScript libraries
Custom Publisher Actions
Creating websites and communities
Mobile applications
Custom report UIs and the Analytics API
Updating the FormulaForce package
Summary
User Interfaces and the Lightning Component Framework
Building a basic standalone Lightning page
Introduction to the Lightning Design System
Building your first component
How does Lightning differ from other UI frameworks?
Lightning architecture
Containers
Introducing the Race Overview Lightning app
Lightning Experience and Salesforce Mobile
Components
Separation of concerns
Encapsulation during development
Enforcing encapsulation and security at runtime
Expressing behavior
Platform namespaces
Base components
Data Service
Object-oriented programming
Object-level and field-level security
FormulaForce Lightning Components
RaceStandings component
RaceCalendar component
RaceResults component
RaceSetup component
Making components customizable
Integrating with Lightning Experience
Using components on Lightning Pages and Tabs
Integrating with Lightning Flow
Integrating with Lightning Communities
Exposing components with Lightning Out
Updating the FormulaForce package
Summary
Part IV: Extending, Scaling, and Testing an Application
Providing Integration and Extensibility
Reviewing your integration and extensibility needs
Defining the Developer X persona
Understanding and managing versioning
Versioning the API definition
Versioning the API definition of the Salesforce APIs
Versioning the API functionality
Translation and localization
Terminology and platform alignment
What are your integration use cases?
Developer X calling your APIs on-platform
Developer X calling your APIs off-platform
Developer X calling your APIs asynchronously through Platform Events
What are your application’s extensibility use cases?
Standard platform APIs for integration
An Apex-callable interface API
Application integration APIs
Providing Apex application APIs
Calling an Apex application API from Apex
Modifying and deprecating the Apex application APIs
Versioning Apex application API definitions
Providing RESTful application APIs
Key aspects of being RESTful
What are your application resources?
Mapping HTTP methods
Providing Apex REST application APIs
Calling your Apex REST application APIs
Versioning Apex REST application APIs
Behavior versioning
Definition versioning
Exposing Platform Events
Exposing Lightning Components
Extending Flow
Versioning invocable methods
Extending application logic with platform extensibility features
Extending application logic with Apex interfaces
Extending application logic with Flow
The MuleSoft platform
Summary
Asynchronous Processing and Big Data Volumes
Creating an object for race data
Using Apex to generate synthetic race data
Indexes, being selective, and query optimization
Standard and custom indexes
Ensuring queries leverage indexes
Factors affecting the use of indexes
Profiling queries
Skinny tables
Handling large result sets
Processing 50k maximum result sets in Apex
Processing unlimited result sets in Apex
Processing unlimited result sets using the Salesforce APIs
Handling billions of records with Big Objects
Salesforce and NoSQL stores
Using a Big Object for race lap history
Importing Big Object data
Using Data Loader to import data into a Big Object
Options to query Big Object data
Synchronous Big Object SOQL queries
Asynchronous Big Object SOQL queries
Asynchronous processing
Asynchronous user experience design considerations
Asynchronous processing with workers and jobs
Implementing a worker with @future
Implementing a worker with Queueables
Implementing a job with Batch Apex
Asynchronous processing with Platform Events
Using high-scale Platform Events to stream data ingestion
Using Change Data Capture Platform Events to compute data
Sending race data telemetry events through the Salesforce DX CLI
Asynchronous processing with Functions
Volume testing
Summary
Unit Testing
Comparing unit testing and integration testing
The testing pyramid on the Salesforce Platform
Introducing unit testing
Introduction to unit testing with Apex
Deciding what to test for and what not to test for in a unit test
Constructor dependency injection
Implementing unit tests with CDI and mocking
Other dependency injection approaches
Benefits of dependency injection frameworks
Writing unit tests with the Apex Stub API
Implementing mock classes using Test.StubProvider
Creating dynamic stubs for mocking classes
Considerations when using the Apex Stub API
Using the Apex Stub API with mocking frameworks
Understanding how ApexMocks works
ApexMocks matchers
ApexMocks and Apex Enterprise Patterns
Unit testing a controller method
Unit testing a Service method
Unit testing a Domain method
Unit testing a Selector method
Unit testing with Lightning Web Components
Introduction to unit testing with Lightning Web Components
Validating that the driver list is correctly bound to the table
Validating that the selected drivers are sent to the server
Unit testing with Salesforce Functions
Integration testing Flow and user interface logic
Flow testing
UTAM testing overview
Summary
Source Control and Continuous Integration
Development workflow and infrastructure
Creating and preparing your scratch orgs
Understanding the developer workflow
Developing with source control
Populating your source control repository
Deploying the code from source control
Developing in scratch orgs with a namespace
Leveraging the Salesforce REST APIs from the Salesforce CLI and custom plugins
Updating your source control repository
Controlling what gets pulled down locally from your org
Managing local files and committing to source control
Hooking up continuous integration
Using continuous integration to maintain code health
Introducing the Jenkinsfile for CI
Installing, configuring, and testing a Jenkins CI server
Exploring Jenkins and CI further
Releasing from source control
Automated regression testing
Alternative Salesforce-oriented CI/CD servers
Summary
Integrating with External Services
Understanding inbound and outbound integrations
Managing inbound integrations
Introducing Salesforce Connected Apps
A Node.js application using a Connected App
Understanding options for outbound integrations
Managing outbound connections with Named Credentials
Calling outbound connections from Apex
Using per-user Named Credentials
Accessing external API services via External Services
Accessing external data seamlessly via External Objects
Integration with AWS Services
Summary
Adding AI with Einstein
Understanding Salesforce Einstein services and products
Understanding Einstein Prediction Builder
Understanding Einstein Discovery
Discovering insights from Formula 1 race results
Understanding Einstein Platform Services
Summary
Other Books You May Enjoy
Index
Cover
Index
The first part of this book will help frame your abilities as a developer within the context of Salesforce. You will learn how to begin building the example application used in this book with Salesforce DX tools and the Salesforce CLI. One key topic you will come to understand early on in your application development is how to design your code to optimise application storage.
If you are an Independent Software Vendor, you will also be interested to learn about application publishing on AppExchange.
By the end of this part, you will understand many of the basic issues and opportunities for improvement you will encounter during application development. This knowledge, especially of concepts such as separation of concerns, will act as a platform for a much deeper discussion of enterprise coding patterns in the next part of this book.
This part comprises the following chapters:
Chapter 1, Building and Publishing Your ApplicationChapter 2, Leveraging Platform FeaturesChapter 3, Application StorageChapter 4, Apex Execution and Separation of Concerns