Jul 8, 2024
46 Views
Comments Off on Visualforce Vs Lightning – Which to choose and When
0 0

Visualforce Vs Lightning – Which to choose and When

Written by

Visualforce:  The Visualforce framework provides a robust set of tags that are resolved at the server-side and that work alongside standard or custom controllers to make database and other operations simple to implement. This is a page-centric web application model. It’s great for basic functionality, but it’s challenging to deliver the new, more dynamic experience that users expect. Fundamentally, this is because it relies on the server to generate a new page every time you interact with the application.

Lightning Component: Lightning components are part of the new Salesforce user interface framework for developing dynamic web applications for desktop and mobile devices. They use JavaScript at the client-side and Apex at the server-side to provide the data and business logic.To deliver a more interactive experience, you need help from JavaScript on the client-side. In this new app-centric model,JavaScript is used to create, modify, transform, and animate the user interface rather than completely replacing it a page at a time. This model is exciting,interactive, and fluid.Both the page-centric and app-centric models have their own advantages and both are here to stay. Combining the models lets applications deliver the right type of experience for the right use case.

A Quick Peek How These Two — Visualforce and Lightning work actually —

Visualforce Lightning
UI Generation Server-Side: User requests a page .The server executes the page’s underlying code and sends the resulting HTML to the browser .The browser displays the HTML when the user interacts with the page, return to step one. Client-Side: The user requests an application or a component .The application or component bundle is returned to the client .The browser loads the bundle .The JavaScript application generates the UI when the user interacts with the page, the JavaScript application modifies the user interface as needed (return to previous step)
Advantages Tried and true model Enables highly interactive and immersive user experiences
It has not a Two-way binding, you need to wait to see update until the whole page get updated fromthe server at the end. By default, it has Two-way binding, once something gets updated it will show up immediately on the UI.
Easy to implement for greater productivity Aligns with Salesforce user interface strategy
Naturally splits large applications into small, manageable pages Built on metadata from the foundation, providing an integrated developer experience
Has built-in metadata integration The Developer Console supports Lightning components, so there’s an integrated developerexperience
Disadvantages Limited interactivity (aside from added JavaScript functionality) Higher learning curve compared to Visualforce
Higher latency Higher complexity than Visualforce–you’re building an application, not a page
Since Lightning components are new, there are still some features that aren’t supported
There are a limited number of out-of-the-box components

Use Cases of Lightning and Visualforce

Lightning:

  •  Developing for Salesforce1 Mobile Application Lightning should be used as Visualforce characteristics, especially the page-centric orientation, can be a poor match for mobile apps with limited, high-latency network connections and limited compute resources. Lightning components, by contrast, was designed specifically to handle this context.
  • For building an interactive experience with JavaScript to meet user experience requirements Lightning should be used.
  • Enabling non-developers to build apps by assembling standard or custom components Lightning App Builder should be used and Lightning components for custom components. Use Visualforce if the required components aren’t yet available.
  • For adding user interface element for example,say someone wants to add a tab to a record home. This task is a simple drag-and-drop in Lightning App Builder.
  • Community for Customer: Building a Community for Customers one should use Community Builder to create a Lightning-based community site leveraging Lightning components.
  • If you are committed to invest in latest technology you should start using Lightning Components.
  • If you are starting a brand-new project you should use Lightning Components. If you’re not familiar with them, there’s no better time than now to learn!

Visualforce:

  • For building a page-centric experience with limited Client-Side logic use Visualforce.
  • If committed to JavaScript Framework such as AngularJS or React continue using Visualforce.
  • For building an interactive experience with JavaScript and there is a need of third party Framework, use Visualforce as a container for third party Framework.
  • Community for Partner: Building a community for partners continue using Visualforce in Salesforce Classic. Explore using Lightning components with Lightning components for Visualforce.
  • Exposing a Public-Facing Unauthenticated Website continue using Visualforce. Lightning components don’t support an anonymous(unauthenticated) user context yet.
  • Rendering pages as PDF in a application use Visualforce. Lightning components don’t support rendering as PDF output yet.
  • Adding to an existing project with lots of Visualforce Pages continue to use Visualforce. Consider moving to Lightning components using Lightning components for Visualforce.

Other Decision-Making points:

What is the business need?

This is what one should be focused on from the start. In my experience, most customers won’t care what technology you use to satisfy their requirements. What they won’t be happy about is you expecting them to compromise their experience so that you don’t have to compromise your technical integrity.The purpose of the exercise is not for you to demonstrate your mastery of the most complex combination of languages and libraries, it is to deliver the experience the customer wants with maximum ROI , and ease of maintenance going forward.

Do you need code at all?

This should always be the first question that you ask yourself when considering custom functionality on the Salesforce platform. If you can find a declarative solution, potentially even one that sacrifices some ease of use for ease of maintenance, always go that route.You can do most things with either of them .

Want to use the Salesforce Lightning Design System?

Works fine with both (even with standard Visualforce components, with a little jiggery pokery).

Want to keep the business logic on the client side?

That means you either need Lightning Components or Visualforce remote methods.

Want to use a third-party JavaScript library?

No problem, you either include it via a standard Visualforce component or a standard Lightning Component.You can’t do some things with one of them .Lightning Components don’t have a built-in unit test framework. Visualforce embedded in Lightning Experience record pages won’t be sized correctly.If you have hard requirements that only one technology supports, then you are golden and the decision is easy. However, it’s more likely that you’ll have hard requirements that only a combination of both technologies supports. In which case, you must continue evaluating the pros and cons.

What have you used in the past?

Consistency is important when creating apps or extending standard Salesforce functionality. Being able to jump straight into a customization and understand the technology and approach used means that productivity is maximized”Š–”Šsomething both your employers and customers will like.Also, while its great for developers to play with the latest and greatest, a customer that finds themselves looking for recruits with Apex, Visualforce, JavaScript, AngularJS, ReactJS is probably not going to be pleased that they have indulged themselves. Always think about what you are leaving behind for others to maintain.

What is the existing skill set?

If you are an Apex and Visualforce shop,building functionality using Lightning Components requires your developers to skill up in JavaScript. Conversely if your developers have been building rich web applications with the business logic in the front end, choosing Visualforce will require them to learn server-side technologies.

What is the budget?

If your customer has presented you with a tight budget, then there probably isn’t money available to skill up existing staff,unless your employer is prepared to pay for that themselves. Even if the money is there, an aggressive timescale (when are they ever not?) means that finding the time to learn will be a challenge. A combination of both means that you should look to play to your strengths rather than take a punt on the unknown.

What is the complexity?

As Visualforce is a mature technology, it has a number of rich standard components that take a lot of the effort out of development”Š–”Šthe input Field component, for example, generates the appropriate widget to capture input based on the field type. Security is also baked in”Š–”Šusing a page managed by a standard controller, if a user doesn’t have access to afield then it will be hidden from them.Lightning components, however, are much younger and only provide the basics. You’ll find yourself writing a lot of code to provide features that you would otherwise get for free, and the chances are that you’ll be able to throw a lot of that code away as the Lightning components framework matures and provides these features out of the box.What do you want out of it?If you are looking for a collection well-designed, well-written and highly re-usable Lightning component out of apiece of work, you won’t get them from your first attempt, especially if you are relatively new to JavaScript. You’ll make decisions that will turn out to be misguided, the framework and requirements will change underneath you, and you’ll end up making compromises to hit the deadline.These compromises usually mean fixing a component in the current use case, as you don’t have the time or the budget to continually refactor and maintain the high re-usability bar that you started out with. That’s okay”Š–”Šthe purpose of doing work is to turn a profit, and burning through the budget (and more) in the pursuit of artificial purity is a pretty quick route to financial problems. Treat it as a learning experience”Š–”Šyou might not have achieved Valhalla this time out, but you know at least one misstep to avoid next time around.Are there existing artifacts?If you have a bunch of business logic currently sitting in Apex classes on the server, then you probably want to favor Visualforce. If you were to use Lightning Components you’d either have tore-implement in JavaScript (and now you have two versions to maintain”Š–”Šcongratulations!)or go back to the server every time the user did anything, which rather misses the point of a client side framework.If you’ve already built a number of re-usable set of Lightning Components that will satisfy many of the customer’s requirements, it makes perfect sense to build these out to satisfy the rest of them. Re-implementing in another technology rarely makes sense”Š–”Šthe best case is that you are on another “platform” and the users don’t notice any difference, the worst case is that you break loads of stuff that nobody asked you to change.

Words for the Salesforce Developers for Lightning Component Development

  • Should have good knowledge of JavaScript. If you have some knowledge of JavaScript then you can start building Lightning Components easily. Lightning Component has all its data logic written in client-side with help of JavaScript.
  • Should have good knowledge of HTML and CSS. Lightning core is the UI. Lightning has a very responsive and interactive UI. One should have a very good knowledge to keep the core of Lightning if some complex requirement comes up.
  • Should have a very creative mind. Lightning is all about creativity. The more you are creative the more you bring out of Lightning.

Summary :

There is no right answer. At least not yet. Once the Lightning Component framework achieves the same richness as Visualforce in terms of standard components and declarative controller functionality, the decision will be more straightforward.As of now, there’s nothing wrong with building in Visualforce, even if it feels like Lightning components are the future. There are millions of Visualforce pages out there. Salesforce have put a lot of effort into making sure that these work correctly in the Lightning Experience,and Visualforce isn’t going away any time soon, so don’t feel guilty for not for asking it.

Article Categories:
Fashion