architecture - Decoupling too complex javascript modules -
right i'm developing pretty huge , complex webapp , have deal huge amount of client-side js code, , make life easier i'm trying decouple code as can.
i hugely inspired nicholas zakas (http://www.youtube.com/watch?v=vxjvfposqhw) , addy osmani (http://addyosmani.com/largescalejavascript) talk scalable js architecture , trying apply of ideas work.
i've separated code across multiple independent modules, , handle intercommunications sort of mediator. approach worked great in cases. there cases think its not enough.
one of modules i'm working on represents pretty complex list-alike structure. here simplified example:

besides rendering logic, module responsible piece of page should handle:
- pagination
- toggling groups
- moving elems , groups around dnd
- cutting / copying / pasting elems , groups
- refreshing certaing groups / elems
- some logic within elems
- may more stuff in nearest future
i had carried out unrelated logic (for example editing , deleting logic carried out module via events), module size still large (over 1k lines of code), , dont know how reduce it. i'm using module pattern modules it's harder separate logic between multiple files.
so came here ask there way decouple complex logic within single module?
update:
i want clarify something. i'm pretty aware of how can separate modules("module" module pattern) across multiple files in code.
but searching new logical way separate concerns within single module ("module" nkz presentation).
to decouple single module multiple files recommend using augmentation pattern found on page http://www.adequatelygood.com/javascript-module-pattern-in-depth.html
additionally, here more resources on creating scalable js applications:
here video of presentation given nicholas zakas on "creating scalable javascript application architecture." http://www.youtube.com/watch?v=7bgvy-s-iag
another resource http://addyosmani.com/largescalejavascript/
knowing these concepts allow build application capable of dropping modules in , out seamlessly. able change module without affecting other module because program loosely coupled. additionally, should choose switch base library, example knockoutjs angular, framework allow swap base library , without breaking of code.
also, using modules , mediator or sandbox make code easier test. testing important in non-trivial application. hope helps!
Comments
Post a Comment