The CRM Recruiter’s Book Review On: Learning Salesforce Lightning Application Development By: Mohith Shrivastava

As many customers transition their Salesforce applications from Classic to the Lightning Experience, they are also thinking of ways to allow their users to be more productive and efficient in their day to day activities.

Therefore, within the Lightning Experience user interface, there are a series of out of the box tools available such as Flow, Process and Application Builder as well as pre-built Lightning Components that a Salesforce Administrator can drag and drop into existing Lightning pages to fit into the “clicks not code” paradigm to provide a better user experience.

While this book briefly touches on those capabilities, this reference guide is geared for the developer who has a more complex and specific set of requirements, where they need to build custom Lightning components to achieve success. To do so, new components are developed with HTML, JavaScript, and CSS to ultimately create a component bundle to expand Salesforce’s out of the box capabilities for areas such as: Lightning Experience, Communities, Mobile, Outlook, Chatter and API’s.

Within this book, Mohith Shrivastava covers the concepts that are available within the Lightning Framework such as the building blocks to form a Lightning bundle, as well as capabilities such as Lightning Flows, Lightning Data Service, Locker Service, and Lightning Out. Lastly, additional development concepts are covered such as Debugging, Performance Tuning, Unit Testing while utilizing the SalesforceDX CLI (Command Line Interface), providing code examples from Github. 

This book provides plenty of examples along with screenshots and a general overview of concepts and I highly recommend the purchase of this reference book to grasp a more in-depth understanding of all the moving pieces involved within the framework.

Below is a summary of each chapter.

Chapter 1 – Intro to the Lightning Framework

An intro into the core components that make up a Lightning app and the architectural differences between the client and server communication and data rendering as a user interacts with the system.

Additionally, Mohith provides a good diagram of the Lightning component life-cycle between a user clicking a button and what happens behind the scenes of the component markup, JavaScript, Controller, JavaScript Helper and Apex controller classes as depicted below

Finally, we are provided an example of how to create a “Hello World” Lightning component using the developer console as well as how to utilize the Lightning Design System to style and format a component.

Chapter 2 – Exploring Salesforce DX

Within this book, Salesforce DX is the development tool of choice and is used in all examples provided. In this chapter, Mohith explains how Salesforce DX is used as a source driven development workflow in utilizing version control and the Salesforce DX CLI (Command Line Interface) to help adopt a Continuous Integration process.

Also outlined is the process and the CLI commands to install DX, the Developer Hub, create a new DX project, build a scratch org, and to set up Visual Studio extension pack. Lastly, we’re shown a good example of the life-cycle and workflow using all the above-mentioned tools to develop a Lightning component, as shown below.

Chapter 3 – Lightning Component Building Blocks

In this chapter, Mohith explains the parts that make up a Lightning component and how they’re used. This includes the component markup (CSS, HTML), the JavaScript controller and the helper. Additionally, we’re shown how to wire the JavaScript client-side controller to the server-side Apex controller.

We also explore examples of how to control the layout and sizes of the Lightning Components to help increase the visual appeal to the end user.

Lastly, we’re shown a diagram of the series of events and actions that takes place between the client and server which really give a great depiction of what is happening technically behind the scenes.

Chapter 4 – Lightning JavaScript API

The JavaScript API is one of the critical pieces that make up the Lightning Component framework. In this chapter, we explore the various JavaScript functions and API’s that are supported, as well as the rendering cycle using the renderer file. Also brought to light is security via the Locker Service to help ensure malicious content and unauthorized access does not occur.

Furthermore, Mohith dives into the functionality of the Renderer JavaScript file and how it’s used if you need to create custom logic for your DOM (Document Object Model) manipulation.  Below is an example of where the renderer file is located and a workflow of how it’s used.

Concluding this chapter, we get an introduction to the Promises API which can help when you have nested callback that can be a challenge to debug and maintain.

Chapter 5 – Events in the Lightning Component Framework

The event driven model is the core of what the Lightning Component Framework uses based on a series of Publisher/Subscribe events using either the application or component event model. In this chapter, we are educated on how component events differ from application events, as well as how to create, register, fire and handle each type of event. We are also provided examples along with associated code to explain how a series of components can communicate with one another such as a child component taking action when it’s corresponding parent triggers it. Lastly, we are shown the optimal design pattern to help make debugging Lightning events less cumbersome.

Chapter 6 – Lightning Data Service and Base Components

One of the new features within the Lightning framework is the Lightning Data Service which provides a developer the ability to take care of Create, Read, Update, Delete (CRUD) operations as well as field level security inherently within the service. Historically, this was needed using APEX coding on the server.  Below are examples of the client/server interaction comparing not using LDS and using LDS.

The idea behind Lightning Base Components is to accelerate development by utilizing the out of the box components and design patterns available to you in SLDS (Salesforce Lightning Design System). 

This chapter provides example on how to use both custom and base components to rapidly achieve LDS functionality as well as the offerings that base components have such as: carousel, tree, data table, etc. to help provides a base set of common functionalities to get a developer going in their development work.

Chapter 7 – Using External JavaScript Libraries in Lightning Components 

To give your Lightning Components additional functionality, a series of external JavaScript libraries can be used, some may already be familiar to a seasoned developer such as JQuery, as well as others that include Chart.JS, Moment.JS, React.JS and Angular.JS. Although, some libraries are not compatible with the Lightning Locker Service, this chapter provides examples of how to make them Locker Service Compliant by using the Webpack Bundler to handle unsupported reference in the library.

Additionally, covered in this chapter are examples of how to make the client-side JavaScript call out to external sites, as well as how to have your Lightning Component communicate with VisualForce or any other I-frame embedded within a Lightning page.

Lastly, using the Lightning:Container component allows for a SPA’s (Single Page Applications) written in React, Angular, Vue, etc. to load inside the Salesforce Lightning Component. We are also shown some of the limitations of this approach with regards to performance, storage and offline caching.

Chapter 8 – Debugging Lightning Components

For any developer, the capability of debugging will always be needed. Here we are shown how to debug the front-end JavaScript code (if you’ve done any APEX development before you should be familiar with the server side debugging techniques) and APEX debugging is not discussed.

Within this chapter, we walk through the Salesforce Lightning Inspector tool to explore ways to inspect issues associated to the events firing and receiving, as well as performance bottlenecks. Additionally, we go through examples and techniques of using the performance optimizer, how to set breakpoints, parsing and catching exceptions, streaming logs, and using the replay debugger in the Salesforce DX CLI. Below is an example of the Lightning Inspector.

Chapter 9 – Performance Tuning Your Lightning Components

As a developer, having a performance problem can cause all your development work to quickly loose its appeal. In this great chapter, we explore preferred options and specific “gotchas” that may cause performance constraints within your Lightning Component and techniques to correct them.  Below is an example of that interface.

Some of the recommended and non-recommended approaches mentioned are using storable actions, avoiding Aura:If in the Aura:Iteration, rearchitecting the solution by moving logic to the controller to create markups conditionally, using the Lighting Data Service, limiting data sets and leveraging the Lightning Base Components (rather than new components from scratch) among many other examples.

Chapter 10 – Taking Lightning Components out of Salesforce Using Lightning Out

Another concept with Lightning Components is the ability to take custom built Lightning Components out of the Salesforce platform to use with any other web application that supports JavaScript, HTML, CSS that might have been built on various technologies such as Node.JS, Heroku, WordPress, Sharepoint, etc. or within the classic VisualForce page.

In this chapter, we are provided some examples of how to deploy Lightning on VisualForce pages and on a custom Node.JS application as well as diving into some of the limitations to consider as not all events and components are supported nor work outside the context of the Lightning experience.

Chapter 11 – Lightning Flows

As most Salesforce practitioners are familiar with declarative features of Flow and Flow Builder, we can integrate Lightning Components within these to provide additional capabilities to meet specific user requirements.

We are provided an example of how-to set-up a Flow using Flow Builder, how to run that flow in the Lightning Experience, then debug the flow and lastly how to add custom components to the flow builder. From these, the author takes the reverse approach on how to embed Flows inside a Lightning Component to pass variables in and out based on a Lightning Component firing and the flow running logic to pass those variables back to the Lightning Component that called it.

Chapter 12 – Making Components Available for Salesforce Mobile and Communities

Utilizing Salesforce Lightning Components within the Salesforce Mobile App and Salesforce Communities can provide the user with a more personal and appealing user-experience.

Within this chapter, Mohith provides step by step instructions and screen shots of how to develop a UI on the Mobile app, and how to set up your Chrome browser to simulate the user experience while providing context on global and Lightning Quick Actions.

Chapter 13 – Lightning Navigation and Lightning Console API’s

In this short chapter, we’re introduced to additional capabilities to enhance the productivity of the user with techniques such as: allowing the user to navigate to various components, pages and tabs by using the Lightning console to provide split views, work spaces, tabs and a utility bar using API’s to do so.

Chapter 14 – Unit Testing Lightning Components

Just like testing APEX on the server side, a developer will need to unit test their functions on the client side. Within the Lightning framework, Salesforce provides a Lighting Testing Service (LTS) which is a set of wrappers for Jasmine and Mocha JavaScript testing frameworks. Jasmine is the primary framework explored in this chapter as Mocha still needs additional libraries to be effective and is the newer of the 2 available.

This chapter, we are given explanations and examples of the different parts the make-up Jasmine, such as Suite (like a test class in APEX), Spec (similar to a test method in APEX), Setup and Teardown (equivalent to @istest setup), and Spies (the same as stubs that prevent actual server calls to be made). Additionally, discussed are the various wrappers that are available from the Lightning Testing Service as well as recommendation on the different test cases.

Chapter 15 – Publishing Lightning Components on the AppExchange

Once a Salesforce Lightning App is developed and tested, a managed package can be created and published on the AppExchange for other users to install and use. Mohith takes us through the various steps to be able to do this such as creating the proper namespace, creating the manage package, documenting your components using the Auradoc file, providing the design file to allow admins to configure attributes to drag components to the Lightning App Builder, Community Builder or Flow Builder, and lastly publishing the component on the AppExchange.

Conclusion

In conclusion, whether you’re a developer that’s new to the Lightning Framework or have been developing Lightning Components for a few years, this book should be a part of your reference collection as it provides great examples and explanations along with helpful screen shots to help expand your expertise within the various layers that are involved with Lightning Component development.

This book can be found on Amazon at:

Leave a comment

Your email address will not be published.

Related Posts