Might be a silly question: is it considered bad pr...
# cfml-beginners
p
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
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
But either way, it's better to keep your lifecycle event handler methods as simple and on-point as possible.
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
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
According to me No You can add custom private functions