5 Lightning Tips for Visualforce Champs!
Many developers and architects have different conception about when to use Visualforce and #Lightning. Some people literally classify it based on just user experience where some classify it based on code architecture it follows. Life is not that difficult, trust me!!
So, let me explain you significant differences between #Lightning and #Visualforce:
1. Lightning is JavaScript driven framework while Visualforce is tag-based framework.
2. In Lightning, UI is generated on client-side while in Visualforce it is generated server side.
3. Lightning is component based framework where Visualforce is MVC framework.
4. Due to component based framework, Lightning is App-Centric while Visualforce is Page-Centric model.
5. Lighting has Lightning Design System for UI which is responsive and supports SPA(Single Page Applications) where Visualforce is not responsive.
One key point to note is; the environment in which a Visualforce page runs when Lightning Experience is enabled is different than the standard Visualforce request in Salesforce classic environment. Oh really! How is that different? In Lightning Experience enabled organizations; Visualforce pages are embedded in an HTML iframe that's displayed inside the Lightning Experience app. This change has a number of consequences that mostly have to do with JavaScript, accessing external apps and iframe inside iframe.
Get you learning started from here:
1. Read Lightning Overview: https://developer.salesforce.com/lightning
2. Learn Lightning Design System from here: https://www.lightningdesignsystem.com/downloads/
3. TrailHead badge for Lightning App Builder: https://trailhead.salesforce.com/en/module/lightning_app_builder
4. Lightning Components Developer Guide: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/qs_aotp_app.htm
So, let's jump on tips quickly:
1. The Mighty Syntax: Developers really need to be very good at JavaScript and should understand event handling and concepts like callbacks, templating, etc.
2. CSS (Cascading Style Sheets): "Lightning Design System" empowers very quick development of responsive SPA BUT it takes time at first shot for developers to ramp up. Don't get afraid and you will catch on it if you keep using it for a week. I feel like king in LDS now but first week was tough for me too :)
3. Understanding Application Architecture: It is very much required that developers should understand where will be what? Like if you have any UI validation then rather than checking it in apex controller, you can do in JS at client side itself. So, make sure you breakdown a requirement in pieces and understand what will sit where? Also, you application will be a component bucket now so you can always add/remove components and no need to work at tag level.
4. Mind-set and Knowing resources: Don't get afraid of learning lightning as it's a future and it will shine your future too! Don't forget that Salesforce and community has created enough of documentation for you to speed up your learning. You just need to pick the right one!
5. Testing: When you go for lightning and specially when you are migrating from Visualforce to Lightning; make sure that you did lots of testing with every aspect. Cross browser testing is a significant one. The changes in the user interface vary from minor to significant. Some key testing scenarios which I learned from are below:
- If page make use of iframes themselves, either with <apex:iframe> or static HTML, being embedded into another iframe could cause some issues.
- If page embeds a Force.com Canvas app, and especially if you have used the Canvas APIs to integrate the app into Salesforce, allocate time for thorough testing as well. Canvas apps use an iframe, and while correctly behaving code should just work, we all know how common perfect code is in the real world.
- Number of related lists available in Salesforce Classic aren't supported in Lightning Experience. The <apex:relatedList> component isn’t a way around this limitation.
If you have any specific questions then feel free to reach out to me on sumi.shingavi@gmail.com
Great post Sumit :)
Well define difference between lightning and Visualforce .... appreciate you effort and for sharing
a nice read, keep it up for helping all of us :-)