Since this post would be written in En, I think it would hardly have any reader. on the other hand, most of my readers have no interest in coding, so , this language issue seems to make some sense.
recently, I’m doing the 6znet refactoring. Inspired by my every day job in hand, and some concept from General interface, finally, I got some direction and stared to do the refactoring which is planed long time ago.
currently, codes in the 6znet is all in a mess, up to the time I did it, I just focused on the interaction and appearance, also I was not so experienced in javascript, so the ugly code is running under a nice suite, lol….
now I realize the importance of the structure, and start the coding layer by layer, from the bottom to the to the top.
the most bottom level of it is mootools, “don’t reinvent the wheel”, I think it’s wasting time to write a framework of its own. And the reason why I didn’t pick Jquery is : it looks more like a quick tool but a structure builder. and mootools is good at this part, although it has some name space complaint. I’m treating this site as a application then a web page, cos it always is and still going to be.
upper a little is the customized classes and utility packages. some of them is the functionality enhancement, some of them is GUI constructor packages. there are 5 very important parts :
1.the request manager
this request manager is controller of all the outgoing request, all outgoing should use this manager. it can control the num of requsts at the same time, sort the requests by priority, cache the callback with out-of-date time setting, max requesting setting…more feature still coming
2.template
when I start this project, I was thinking how to implement the data and UI template together. At first, I just want to have a area of saving all the templates in some div in the page which is hidden. disadvantage is obvious, you can not save all the templates in one page, the num of UI component is unpredictable, save all of them in one page is hell for further maintenance.
then I thought, maybe it’s ok to get the templates(html slice) by XHR, but the problem is we have to treat the well formated html as a string instead of a DOM element, and if we use “innerHTML” to have it place into the dom tree, there is some weird problem in IE(can not get the element inserted by innerHTML), even this was fine, but how should we put the dom and behavior code together? preload in page? the same issue as the first solution. get from XHR? js mixed together with HTML? hell…….
then I thought, it’s a good idea to translate the HTML to some kind of json, and everything from the XHR would be in JS, this solution also made the cross domain request possible, everything seems perfect but the question is , HOW?
Ding! I found JSML. it gave a total solution, translate the HTML to the JSON, back and forth. A template data binding solution, BST (browser side template. this is some kind of similar with GI, in GI, all the data is saved in the format of XML).
I love this way of dealing with DOM, data and behavior. And I have wrapped the them in the template utility package. also, it’s taking the advantage of the request manager’s cache mechanism.
3.PageBus
it’s extremely handy when you are making different modules working together. especially when you are dealing with some unsynchronized functions. but the ugly part is when you are doing the unsubscription. In the project of my daily work, we also met with this one, I gave a solution injecting some property bundles in the object doing the subscribing, but it’s not so good, cos it’s kind of hack, I’m now trying to avoid doing this in the same way.
4.the logger
thank God we have firebug, but IE don’t have one, damn! so the logger is totally for IE, to monitoring the status while debugging in IE. Logger is good thing, we can almost replace all the inline comments with the logger in the design time.
5.bind method with Dom elements
I wish I was not that Mars when I realize it.
well, that’s all I want to record, if you are reading word by word all the way down here, good for you, have a chocolate(refer to big bang theory S03E03).
one more thing : I created a project in google code, although most of the codes in the svn is POC, welcome reviewing and giving feed back, I’ll keep updating as often as I can.
Again, good for you.