开发者

Advice for refactoring cfmodule into... cfc's?

开发者 https://www.devze.com 2023-03-21 23:09 出处:网络
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 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. :)

0

精彩评论

暂无评论...
验证码 换一张
取 消