I have been assign a existing apex class, it has more than five thousand lines. I am bit confused how can I read entire code so that I can get detailed info about the class functionality. Any help would be appreciated.

1 Answer 1


Your question is a bit broad for our forum, but I'll throw out some pointers from my experience.

The number one thing to remember is not to get hung up on the details. Stylistic quirks can be hard to let go, but paying any attention to them in such a huge mess is going to do you no favors. One concession to this rule that I usually make is to spend a little time normalizing the indentation, so the structure of the code is easier to visually interpret.

One thing you should do to help you grok what is going on is to build an abstract syntax tree. Understanding the structure of the code is what you need to get down first. You can do it in your head or on paper without much more knowledge than that, and I know Robert Sösemann is working on a plugin for Eclipse that you can use if that is your IDE of choice. I haven't got Eclipse running on my machine yet, so I can't provide you with specific installation instructions, unfortunately. Related: #CodeMetricsForApex and @CodeClimate

  • 3
    The Force.com IDE's Outline view is working(ish), which has helped me more than once.
    – sfdcfox
    Commented May 20, 2016 at 3:30
  • 3
    Does it also build an AST for you? It seems there are a couple different options for how to do it. I certainly don't have much experience with which one is best. I usually use paper; it helps me think. But with 5000 lines, I doubt that would be very effective.
    – Adrian Larson
    Commented May 20, 2016 at 3:32
  • 3
    Nah, but you get a list of members, functions, etc. It's better than nothing. Usually once a function gets more than about 100 lines, I usually take the time to refactor. I really like the AST tool you linked though.
    – sfdcfox
    Commented May 20, 2016 at 3:49
  • 4
    OP's issue brings to mind the Prepare Three Envelopes strategy
    – cropredy
    Commented May 20, 2016 at 3:55
  • 2
    @sfdcfox I do believe he's looking for contributors.
    – Adrian Larson
    Commented May 20, 2016 at 4:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .