Highlighted

Fixing CFC code ideas

Explorer ,
Feb 17, 2016

Copy link to clipboard

Copied

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

Views

485

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Fixing CFC code ideas

Explorer ,
Feb 17, 2016

Copy link to clipboard

Copied

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

Views

486

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Feb 17, 2016 0
Most Valuable Participant ,
Feb 17, 2016

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 17, 2016 0
Explorer ,
Feb 18, 2016

Copy link to clipboard

Copied

"

Branch target offset too large for short

"



Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 18, 2016 0
Most Valuable Participant ,
Feb 18, 2016

Copy link to clipboard

Copied

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-...

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 18, 2016 0
Explorer ,
Feb 18, 2016

Copy link to clipboard

Copied

Thank you for the time.

I know that the problem I have is too many cffunctions with lots of lines of html formatting.

What I am trying to figure out is do I pull all the html and conditional formatting out of the cfcs and leave that in regular cfm files and just use the cfc to do the queries?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 18, 2016 0