#forcewebinar
Speaker
Paul Battisson
Technical Architect, Mavens Consulting
Summer ‘14 Force.com MVP
@pbattisson
#forcewebinar
Safe HarborSafe harbor statement under the Private Securities Litigation Reform Act of 1995:
This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the
assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we
make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service availability, subscriber
growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any
statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services.
The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, new
products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in
our Web hosting, breach of our security measures, the outcome of intellectual property and other litigation, risks associated with possible mergers and acquisitions,
the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth,
new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger
enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-
Q for the most recent fiscal quarter ended July 31, 2012. This documents and others containing important disclosures are available on the SEC Filings section of the
Investor Information section of our Web site.
Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be delivered
on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc.
assumes no obligation and does not intend to update these forward-looking statements.
#forcewebinar
@salesforcedevs / #forcewebinar
Go Social!
Salesforce Developers
+Salesforce Developers
Salesforce Developers
Salesforce DevelopersThe video will be posted to YouTube
& the webinar recap page
(same URL as registration).
This webinar is being recorded!
#forcewebinar
▪ Don’t wait until the end to ask your question!
– Technical support will answer questions starting now.
▪ Respect Q&A etiquette
– Please don’t repeat questions. The support team is
working their way down the queue.
▪ Stick around for live Q&A at the end
– Speakers will tackle more questions at the end, time-
allowing.
▪ Head to Developer Forums
– More questions? Visit developer.salesforce.com/forums
Have Questions?
#forcewebinar
Agenda
1. Assumptions/baseline setting
2. Page Performance
1. Viewstate
2. Apex Code
3. Resources
3. Some Tips
4. Asynchronous Pages
#forcewebinar
What is Viewstate
Whenever an <apex:form> tag is present on a
Visualforce page an encrypted, hidden <input> field is
added
This page tracks the state of the Visualforce page and
Apex controller between server requests
It is the state of the current view within our MVC setup
#forcewebinar
What does it track?
Non-transient data members in the related controller
and controller extensions
Objects reachable from non-transient data members in
controllers and controller extensions
The page’s component tree and associated state
Housekeeping data for Visualforce (small amount)
#forcewebinar
What Fields Require Viewstate?
<apex:input*>
<apex:command*>
<apex:action*>
<apex:select*>
<apex:inlineEditSupport>
#forcewebinar
Positives and Negatives of Viewstate
Why it is great Why it is not so great
• Automatically tracks field
values for you
• Enables AJAX to be
simple
• Allows re-rendering of the
page
• Is (rather can be) bulky
• Limited to 135KB
• Complex AJAX is not
really possible
• Difficult to understand the
bottlenecks
#forcewebinar
Main Apex Items Impacting Page Performance
Expensive/Long Running Code
Slow queries
Inefficient looping
Synchronicity
#forcewebinar
Javascript, CSS and Images
Salesforce static resources make the loading of
JavaScript, CSS and Images easier
CDN based delivery
Caching
Bundling in zip files
No cross site requests
#forcewebinar
Transient Keyword
The transient keyword can be applied to data
members that are only required for the duration of the
page request
Items marked as transient are not stored and
transmitted in the viewstate
#forcewebinar
Query Speed
Ensure queries return the smallest amount of data
possible
Utilise indexed fields
– Standard: Name, Id, RecordTypeId, CreatedDate,
LastModifiedDate, Foreign Keys, Email (Lead and Contact only)
– Custom: External Ids, Unique Fields, Custom Indexes
http://goo.gl/gHmUFm Query & Search Optimization
Cheat Sheet
#forcewebinar
Looping Through Collections
Not all looping methods are equal
– Slow
• for(Integer i=0; i<collection.size(); i++)
– Faster
• for(Integer i=0, j=collection.size(); i<j; i++)
http://goo.gl/mR5GZe
#forcewebinar
Javascript Remoting & Visualforce Remote Objects
Javascript Remoting Visualforce Remote
Objects
• Integrate Javascript with
Apex directly
• No viewstate
• Not API based
• Requires you to handle
the callback
• Standard Controller for
Javascript/Async
• No Apex
• Same advantages of
Javascript Remoting
• Complex data models
#forcewebinarChallenge Yourself! http://developer.salesforce.com/trailhead
• Interactive learning paths
• Earn badges and points
• Declarative and Programmatic
BRAND NEW! Introducing Trailhead
#forcewebinar
New App Builders
http://www.udacity.com/salesforce
http://ccoenraets.github.io/salesforce-
developer-workshop
Developer WorkshopFast Track Tutorial for Experienced
Developers
Experienced App Builders
More Free Online Tutorials
#forcewebinar
Survey
Your feedback is crucial to the success
of our webinar programs. Thank you!
http://bit.ly/DevAdvVF
#forcewebinar
Q & A
Survey Link: http://bit.ly/DevAdvVF
Paul Battisson
Technical Architect, Mavens Consulting
Summer ‘14 Force.com MVP
@pbattisson @forcedotcomcast