Skip to main content
Inspiring
February 18, 2016
Question

Fixing CFC code ideas

  • February 18, 2016
  • 1 reply
  • 738 views

I have an application running CF8. One of the CFCs is very large and breaks when trying to upgrade to a newer version of CF.

I use the functions in the CFC to build html docs that can be displayed or emailed. How should I go about refactoring this cfc to make it work?

Format is currently like this:

function - get order

     stored procedure

function - get order details

     stored procedure

function - display order

     several hundred lines of html that get pulled back to the web page or emailed

This topic has been closed for replies.

1 reply

Carl Von Stetten
Legend
February 18, 2016

I would split the CFC methods that make up your "model" (business logic) from those that provide content to views (display logic), especially if they might have access="remote".

Before going down that path, though, can you clarify what you mean by "breaks"? Specific errors would be helpful.

Inspiring
February 18, 2016

"

Branch target offset too large for short

"



Carl Von Stetten
Legend
February 18, 2016

Googling that error message and "ColdFusion" together got me these possible solutions (actually these are only the first 5 or so results):

Branch target offset too large for short

http://stackoverflow.com/questions/2029292/why-does-a-long-cfc-file-work-in-cf8-but-not-cf9-getting-branch-target-offset…

http://www.coldfusionmuse.com/index.cfm/2007/9/28/Branch.Target.Offset

Google Groups

ColdFusion - Branch Target Offset Too Large for Short

Seems the most likely culprits are:

  • excessive switch/case branching
  • wrapping switch/case branching or try/catch blocks inside a CFTRANSACTION
  • concatenating large strings inside CFTRANSACTION
  • using CFDUMP to output a large amount of data (a large query or complex structure)
  • excessively long/complex methods - solved by refactoring into helper methods called by the complex method

It's hard to say which one applies to you, because you haven't provided a stack trace.  Read over the links (or Google the error message and read all of the results) and compare them to the first few lines of the error stack trace.