On 12/21/10, Scott Koon <[email protected]> wrote:
> I've done this as well. Basically the legacy global functions turn into
> functions that just forward on a call to my refactored code. I pull
> everything out of the global function and put it into a namespaced object,
> then call the namespaced object from the global function. After I verify
> that I'm calling it correctly, I start putting tests around the namespaced
> functions and refactoring them as necessary. You still may need to keep the
> legacy global functions around rather than refactor the entire app, but you
> get a better handle on the code.
>

[snip top posted prev msgs].
See also:
<http://en.wikipedia.org/wiki/Posting_style#Interleaved_style>

The technical ideas are fine, but I do not agree that they are the
solution. And actually, in this case, pulling everything into one
large global function will result in a one big function.

Doing that just transfers the ball of mud from being global to being
namespaced. No benefit is gained. It can actually be harder to work
with. I remember `YAHOO.mst.code`; where they'd taken the "Crockford"
module pattern and placed all of the application code in a closure.
The interface object did not have a specific role. Trying to extract
thing like the tooltip code from that 1100+ line blob of a closure was
difficult. There were parts related to the scheduler, and I can't
remember what else.

I did then what I advocate now: I attempted to organize and group bits
of functionality into abstractions. Even if the abstraction is only
used in one place, just take that chunk out and put it on its own,
away from the page implementation code. That way, it was easier to
read what the page implementation code was doing without wading
through all those LOC.

Don't stuff everything into the closet; get it organized.

Garrett

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to