Might be a silly question: is it considered bad practice to put custom private functions in the Application CFC? Perhaps in order to consolidate code that ends up in the lifecycle methods?
a
Adam Cameron
04/23/2023, 4:59 PM
If the private method is just a refactoring of the method that calls it: no problem at all.
However whenever one extracts code into a private method, one should start to think whether that code belongs in a different class completely.
šš» 1
Adam Cameron
04/23/2023, 5:00 PM
But either way, it's better to keep your lifecycle event handler methods as simple and on-point as possible.
Adam Cameron
04/23/2023, 5:40 PM
BTW, Peter: if you are asking about a tactic to improve your code, it is never a silly question. It's a question really a lot more people ought to be asking, based on what I see out in the wild.
Ask the questions.
p
Peter Hoopes
04/23/2023, 5:42 PM
Thanks! - I am looking to clean up some of the long groups of code in my onApplicationStart and onReqeustStart methods. Ultimately, Iām working on getting Coldbox integrated in my site so I can start to move code in to better places using that. But Iām having trouble getting it to work with my existing Application.cfc and as I was looking to figure this out I figured I could refactor code for readability and simplicity. Thanks for notes!
š 1
g
gsr
04/23/2023, 7:36 PM
According to me
No
You can add custom private functions