Lightning Component Development Best Practices

The Lightning Component Framework makes it easy to build responsive apps for any device on the Salesforce platform. This course will teach you best practices that will optimize app performance.
Course info
Level
Intermediate
Updated
Dec 11, 2017
Duration
2h 6m
Table of contents
Description
Course info
Level
Intermediate
Updated
Dec 11, 2017
Duration
2h 6m
Description

Are your Lightning Components performing at the best level they can? Are they secure? Will they scale well as you start to build more complex Lightning Applications? In this course, Lightning Component Development Best Practices, you'll learn the answers to these questions and more. First, you'll find out what simple best practices you can incorporate to improve client-side rendering. Next, you'll learn how to enhance server-side efficiency. Finally, you'll discover what you can do to ensure your components are secure. When you are finished with this course, you'll have the confidence to build Lightning Components that run "Lightning Fast".

About the author
About the author

Sara Morgan Nettles is a Certified Salesforce Advanced Developer and Platform Developer I and II, who began her software development career twenty years ago working primarily with Microsoft technologies. She now focuses on bridging the gap between .NET and Salesforce and has written numerous books and articles, as well as being a regular speaker at Dreamforce

More from the author
Section Introduction Transcripts
Section Introduction Transcripts

Course Overview
Hi everyone, my name is Sara Morgan Nettles, and welcome to my course, Lightning Component Development Best Practices. I am a Salesforce-certified platform I and II developer, and I work for the Trailhead team at Salesforce as a technical curriculum engineer. This course is all about what best practices you can apply to your Lightning Components to ensure that the apps you build are not only responsive, but secure and scalable. You can think of this course as part two from my first course titled Getting Started Building SPAs with Lightning Component Framework. It will also extend upon techniques covered only briefly in my second course titled Customizing Salesforce with Lightning Components. In this course we will cover specific things you could do to improve both the client and server-side performance of your Lightning components. We will also look at ways you can reuse code and complex applications, as well as identify things you could do to improve the communication between your components. And finally, we will wrap with a discussion about security and I will call out four mistakes you should never make. By the end of this course you should have the confidence to build Lightning components that render lightning fast. However, keep in mind that this is not a beginner-level course. You should already be familiar with Lightning component development and the Salesforce. com platform. If this is all new to you then I suggest you first check out one of my other two courses about Lightning development. I hope you'll join me on this journey to improving the performance of your Lightning components with the Lightning Component Development Best Practices course at Pluralsight.

Introduction
Hello. Welcome to Lightning Component Development Best Practices. My name is Sara Morgan Nettles and I am so excited you decided to join me for this course. I've been doing Lightning development for over 2 years now, and this is actually my third Pluralsight course about component development; but this course, I have to tell you, is by far my favorite, and I'm hoping it is yours too. However, this is not a beginner's course and so I'm going to assume you already know a good bit about doing Lightning development and that you now want to take your skills to the next level and really fine-tune your applications with best practices. I will begin by focusing on several things you can do on the client side to not only make your Lightning components look better, but perform better too. I will then switch to the back-end and go over a few keys ways you can improve server-side performance, as well as make sure you are rendering data that is secure. Next up is the concept of modularizing your code, which is a software design technique that will allow you to better reuse your existing code and we will look at two different ways to do that. Then I will go over things that make Lightning development so different from traditional app development, especially when it comes to component communication, and we will look at some specific things you could do to make this communication happen more smoothly. Last up, I will focus on what security considerations should be kept in mind when designing your components and list a few mistakes you should always avoid.

Enhancing Efficiency on the Server
Hi, welcome back to Lightning Component Development Best Practices. In this module I'm going to switch the focus from the client-side to the server-side, and look at what key things you can do to enhance the efficiency of your service-side actions. I'll begin by discussing what main considerations you need to make when it comes to accessing data from the servicer. Then we will once again update the Race Tracker App so that it takes advantage of one of the easiest ways to implement caching, and that is through the use of storable actions. From there we will cover what changes are needed to enforce FLS, or field-level security, since this is something not automatically enforced in AuraEnabled actions. And finally, we will look at an example of using the Lightning data service, which allows us to create a new data record without writing a single line of Apex code. For all you visual force developers you can think of this as the standard controller for Lightning components, so stay tuned.

Reusing Code in Complex Applications
Welcome back to Lightning Best Practices. In this module we are going to take a look at what options you have when it comes to reusing code in your Lightning components. This is something you will definitely want to consider as you start to build out more components and then use them to assemble more complex applications. I will begin by talking about a software design technique known as modular programming, and focus on what it's biggest benefits are. Just like in all the other modules we will take a look at how you can implement a solution by making a change to the Race Tracker App. And we will actually take a look at two solutions that accomplish the same thing. The first solution involves creating a JavaScript library as a static resource and then using it from within one of our race components. But as you will see this solution does have a drawback, and so, the next step will be to implement a solution involving a service component, and a sometimes overlooked, but really cool feature in the Lightning component framework, known as the Aura method. So, please join me.

Avoiding the Pitfalls of Inter-component Communication
Hello again. In this module we are going to focus on a topic that can be a little confusing, but is very important to understand when it comes to creating components. As I'm sure you now realize, Lightning component development is very different than some of the more traditional models of application development. And one of the things that can make it challenging for people that are new to it, is the concept of inter-component communication. So we are going to spend some time understanding how this works, and hopefully help you avoid some of the things that can impact performance. I will begin by going over ways that Lightning component development differs from other types of page-centric development, such as Visualforce. And then I will cover how component communication works in Lightning and the different ways you can send data between components. Next up I will use the very cool Salesforce Lightning Inspector to demonstrate how you can improve the performance of the Race Tracker App by using a little-known concept known as unbound expressions. From there we will also take a look at improving component performance by limiting the number of data fields returned by the Lightning Data Service or force:recordData tag. And because the rendering cycle is so critical to component performance, I will go over what happens exactly during both the rendering and rerendering lifecycles. So stay tuned.

Enforcing Security and Mistakes to Never Make
Hi, welcome to the last module in this Lightning best practices course, in which I will focus on enforcing security and will even list a few mistakes you should never make. The first thing I will cover is the Lightning domain and what exactly that includes. I will also go over some of the things that make working within the Lightning domain challenging, especially the use of JavaScript. And then broadly cover some of things that have been put in place to help remove vulnerabilities, such as LockerService and the Content Security Policy. I will then show you how to use the Salesforce CLI, or command-line interface, which includes a linting tool for Lightning components. Running this tool against your Aura components will use default roles to tell you whether your code includes recommended best practices and LockerService requirements. From there I will show you how to secure attributes using the access attribute, which is a good way of preventing malicious components from tampering with private data. And finally, I will go over a few very important mistakes you should never make when creating your components.