oop - Handling different UI behaviors based off different application states -


i have application has handful of states share single ui. thing is, depending on application state, components of ui doing different things.

in 1 state, mousing on component might bring tooltip, in might serve way 'add list,' or such behavior.

for now, have single ui class many component subclasses. ui passes callback components, might call when interacted with. of now, behavior dictated simple switch statement in ui checks state , returns behavior, seems risk increasing complexity unnecessarily.

the solutions i've thought of have different ui class per state, behaviors appropriate state included in methods. have 'dictionary' of methods in ui, method called

dosomething[currentstate]() 

the problem have create identical methods in ui every single state.

the final solution have ui no logic processed on own. component's of ui given callbacks 'state manager,' in turn has knowledge of ui's methods call upon.

what best way go this?

an application consists of modules, , each module should have dependent components.

in case, each state should different module. "in 1 state, mousing on component might bring tooltip, in might serve way 'add list,' or such behavior.", behavior implemented in each module, , modules have component(by extends base class or composition , or other way).

this make code cleared, , can replace module easier, more classes.

and think using state decide behavior should used in low-level code piece , in 1 module.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -