How to refactor to cleaner version of maintaing states of the widget
Posted
by
George
on Programmers
See other posts from Programmers
or by George
Published on 2013-06-24T14:09:24Z
Indexed on
2013/06/24
16:36 UTC
Read the original article
Hit count: 226
Backstory
I inherited a bunch of code that I'd like to refactor. It is a UI application written in javascript.
Current state:
We have main application which consist of several UI components. And each component has entry fields, textboxes, menus, etc), like "ticket", "customer information", etc. Based on input, where the application was called from, who is the user, we enable/disable, hide, show, change titles.
Unfortunately, the app grew to the point where it is really hard to scale, add new features. Main the driver (application code) calls set/unset functions of the respective components. So a lot of the stuff look like this
Main app unit
function1() {
**call_function2()**
component1.setX(true);
component1.setY(true);
component2.setX(false);
}
call_function2() {
// it may repeat some of the code function1 called
}
and we have a lot of this in the main union.
I am cleaning this mess. What is the best way to maintain the state of widgets? Please let me know if you need me to clarify.
© Programmers or respective owner