Skip to main content
Inspiring
Feb 18, 2016 3:12 AM UTC
Question

Fixing CFC code ideas

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 is closed to new replies. Start a new post to keep the conversation going.

4 replies

Carl Von Stetten
Legend
Feb 18, 2016 4:50 AM UTC

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.

Translate
Inspiring
Feb 18, 2016 3:17 PM UTC

"

Branch target offset too large for short

"



Translate
Carl Von Stetten
Legend
Feb 18, 2016 4:23 PM UTC

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.

Translate