Advice for refactoring cfmodule into... cfc's?
I have never wrote a line of cfmodule
myself. However, now is the time to refactor. What steps do you usually take to refactor cfmodule
into cffunction
/ .cfc?
I'm thinking... refactor them into cffunctions
(attributes
becomes arguments
), and return struct for multiple values, value for single value. Then group related functions into CFC's, and sepa开发者_JAVA百科rate DB access into DAO/Gateway object. Unit test the hell of each of them.
Alternative, my colleague is thinking, maybe we should use a CFC for each 'flow' of cfmodules, and use obj's variables.instance
scope as caller
scope, then return the instance
struct at the end of the 'flow'? Easier, but doesn't seem very testable.
Anyone has exp with refactoring cfmodule
's?
Refactor your objects into CFC's as you're thinking.
Refactoring the application into divisions based off of the current procedural use is the wrong approach for sure. You basically hard coding your business logic to your value objects, which is a no no.
When it's time to add functionality with your existing codebase, you'll be glad you didn't group your logic in with your data. :)
精彩评论