logo
MENUMENU
  • Services
        • Salesforce

        • Salesforce OverviewWe help our clients to make the most out of their technology investments.
          • Salesforce Overview
          • Systems Integration
          • Managed Services
          • Field Service Lightning
          • Salesforce CPQ
        • Verint

        • Verint OverviewOur services cover Implementations, Upgrades, Migrations, Reporting Solutions & Application Support.
          • Verint Overview
          • Verint Knowledge Management
          • Verint KM Integrations
          • Verint Omni-Channel
          • Verint Unified Desktop & Case Management
          • Verint Workforce Optimization
          • Verint Intelligent Virtual Assistant
          • Verint Robotic Process Automation
        • Artificial Intelligence

        • Artificial Intelligence
          • AI Overview
          • Data Engineering
          • Analytics/BI
          • Predictive Analytics
          • Computer Vision
          • Natural Language Processing (NLP)
          • ML Ops
        • Cloud & Mobile Apps

        • Cloud & Mobile App Development OverviewOur services cover Implementations, Upgrades, Migrations, Reporting Solutions & Application Support.
          • Cloud & Mobile App Development Services
        • Let’s Get
          Started.

        • Let’s talk about how SPAR Solutions
          can positively impact your business.

        • START TODAY
  • Company
    • About Us
    • Why Work At SPAR
  • Resources
    • Blog
    • Case Studies

GET STARTED 1-855-772-7765

GET IN TOUCH
  • Services
    • Salesforce Overview
      • Salesforce Overview
      • Systems Integration
      • Managed Services
      • Field Service Lightning
      • Salesforce CPQ
    • Verint Overview
      • Verint Overview
      • Verint Knowledge Management
      • Verint KM Integrations
      • Verint Omni-Channel
      • Verint Unified Desktop & Case Management
      • Verint Workforce Optimization
      • Verint Intelligent Virtual Assistant
      • Verint Robotic Process Automation
    • Artificial Intelligence
      • AI Overview
      • Data Engineering
      • Analytics/BI
      • Predictive Analytics
      • Computer Vision
      • Natural Language Processing (NLP)
      • ML Ops
    • Cloud & Mobile App Development Overview
      • Cloud & Mobile App Development Services
  • Company
    • About Us
    • Why Work At SPAR
  • Resources
    • Blog
    • Case Studies

Salesforce.com – Overcoming Apex code limits

Home > Force.com Development > Salesforce.com – Overcoming Apex code limits

Salesforce.com – Overcoming Apex code limits

December 23, 2016

Salesforce’s cloud platform (force.com) provides a lot of flexibility for customizations, with Apex code being the most common way to develop new functionalities on the platform. However, unlike development stacks like Java and .Net, there are limits imposed by the shared force.com platform. This is to ensure that no single customer takes up too many computing resources, and hence there are limits on the amount of Apex code as well. As customers continue developing new customizations using Apex, it is likely that they will start reaching the code limit at some point in time.

apexcodelimit-cartoon

Before we dive into details around Apex code limits, let us understand the best practices for building applications on the force.com platform. Architects and developers should always check if the functionality that users have requested already exists in a professional, well-constructed appexchange package. That should almost always be the first option considered before going down the path of custom development. If there are no appropriate products available, we also need to evaluate if the functionality is well suited for development on the force.com platform. For the purpose of this article, we will assume scenarios where complex customizations are required on the force.com platform, which in turn requires us to better understand Apex code limits.

According to currently available documentation from Salesforce[1], the percentage of Apex code calculated for an org is the total number of characters of all apex classes and triggers divided by the total character limit of 3,000,000, expressed as a percentage. For e.g., if the total characters used in an org is at 1,500,000, the org would have reached 50% of it’s Apex code limit.

Some key points to note about the computation of this count:

  • The character count includes spaces, tabs and other formatting characters
  • Any code in a class defined with @isTest annotation (test class), and any commented lines in a class or trigger are not counted against this limit
  • Apex code in installed managed packages are not counted against this limit

Now that we understand the calculations done by Salesforce, let’s look into the options available to avoid reaching these limits.

While avoiding extra spaces and unnecessary tabs seems like a possible option, we expect that most (reasonable!) developers would not use a high number of those characters to make it a significant item. Well indented, readable code is a highly regarded software engineering best practice, and developers need to ensure that they follow it to an optimal level.

Salesforce can also increase Apex code limits if clients request an increase. However, before increasing this limit, Salesforce typically conducts a review process. Clients will have to justify the need to increase this limit, and also show what efforts they have taken in refactoring their code. While Salesforce will, under justified conditions, increase this limit, clients should recognize some lurking pitfalls. More lines of code also means there is more code to test and maintain, and also increases the dependence on adequate trained staff to support this custom code.

The last option is to leverage the concept of managed packages since they do not count against code limits. This method is similar to how appexchange packages work, and requires a good understanding of the force.com platform, and it’s code migration and deployment options. Developers can migrate code in a modular fashion into private managed packages which can then be deployed into their orgs. This may offer a very clean approach to the problem of code limits, and even offer other benefits to managing your org, but is a fairly complex process that should be handled by experienced developers with a lot of care.

In summary, to avoid  running into Salesforce’s Apex code limits,  customers can follow the steps given below:

  1. Evaluate appexchange packages to avoid custom development
  2. Where custom development is required, develop modular, optimizated code
  3. Consider using managed packages to avoid running into apex code limits
  4. As a temporary measure, contact Salesforce to increase apex code limits

 

SPAR Solutions has experience developing and managing complex applications and integrations, including managed packages on the force.com platform. Our team is available to help you with any questions or challenges you may be facing with your current implementation.

Like to have us contact you? Click here

Swami Ganapathy
+ posts
  • Swami Ganapathy
    https://sparsolutions.com/author/sparwpadmin/
    SPAR’s Commitment to Diversity, Equality and Inclusion
  • Swami Ganapathy
    https://sparsolutions.com/author/sparwpadmin/
    A Complete Guide to Salesforce Field Service Lightning
  • Swami Ganapathy
    https://sparsolutions.com/author/sparwpadmin/
    Salesforce CPQ - Key features overview
  • Swami Ganapathy
    https://sparsolutions.com/author/sparwpadmin/
    Corrupted Excel file from Visualforce

Filed Under: Force.com Development, Salesforce.com, Uncategorized Tagged With: Apex, Governor Limits

Search

Categories

  • Apex Testing
  • Big Data
  • Force.com Development
  • General
  • Healthcare
  • Highlighted
  • How to
  • Integration
  • Knowledge Management
  • Salesforce Field Service Lightning
  • Salesforce.com
  • SFDCHighlights
  • Uncategorized

Archives

  • September 2021
  • August 2021
  • June 2021
  • May 2021
  • March 2021
  • January 2021
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • March 2019
  • June 2017
  • December 2016
  • June 2016
  • December 2015
  • November 2015
  • October 2015
  • July 2015
  • February 2015
  • January 2015
  • October 2013
  • February 2013
  • January 2013
  • December 2012

Ready to Get Started?

Let’s talk about how SPAR Solutions can help you drive greater automation

Get in Touch

Ask us how to get started today.

SPAR Solutions logo

Terms of Service

OFFICE

375 Northridge Rd
Suite #400
Atlanta, GA 30350

CALL US

1-855-772-7765

Copyright © 2020, All Rights Reserved by SPAR Solutions. Digital Marketing by